]> granicus.if.org Git - vim/commitdiff
patch 8.2.0485: Vim9 script test fails v8.2.0485
authorBram Moolenaar <Bram@vim.org>
Mon, 30 Mar 2020 19:28:39 +0000 (21:28 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 30 Mar 2020 19:28:39 +0000 (21:28 +0200)
Problem:    Vim9 script test fails.
Solution:   Stricter condition for adding new local variable.

src/version.c
src/vim9compile.c

index 8a8c45c14f6b00b48a7dba9394917d6d40be45dc..c5f1a85cbbdec18d2080947d74d2a371599862aa 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    485,
 /**/
     484,
 /**/
index 1e8cd03d02455e3c7eb346716e9b1084f0055938..18fb549cc825c69e1ceaca6910846f3bb98a03e9 100644 (file)
@@ -3446,6 +3446,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
     size_t     varlen;
     garray_T   *instr = &cctx->ctx_instr;
     int                idx = -1;
+    int                new_local = FALSE;
     char_u     *op;
     int                opt_type;
     assign_dest_T dest = dest_local;
@@ -3660,6 +3661,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
        idx = reserve_local(cctx, arg, varlen, cmdidx == CMD_const, type);
        if (idx < 0)
            goto theend;
+       new_local = TRUE;
     }
 
     if (heredoc)
@@ -3721,12 +3723,12 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
 
        // Compile the expression.  Temporarily hide the new local variable
        // here, it is not available to this expression.
-       if (idx >= 0)
+       if (new_local)
            --cctx->ctx_locals.ga_len;
        instr_count = instr->ga_len;
        p = skipwhite(p + oplen);
        r = compile_expr1(&p, cctx);
-       if (idx >= 0)
+       if (new_local)
            ++cctx->ctx_locals.ga_len;
        if (r == FAIL)
            goto theend;