changeset 19858:cf09c0962608 v8.2.0485

patch 8.2.0485: Vim9 script test fails Commit: https://github.com/vim/vim/commit/01b3862956260fdb5fb81b81a28f4749a92699c0 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 30 21:28:39 2020 +0200 patch 8.2.0485: Vim9 script test fails Problem: Vim9 script test fails. Solution: Stricter condition for adding new local variable.
author Bram Moolenaar <Bram@vim.org>
date Mon, 30 Mar 2020 21:30:05 +0200
parents afd8e01eba34
children 904b25746b64
files src/version.c src/vim9compile.c
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    485,
+/**/
     484,
 /**/
     483,
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3446,6 +3446,7 @@ compile_assignment(char_u *arg, exarg_T 
     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 
 	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 
 
 	// 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;