changeset 24281:243985ba92b5 v8.2.2681

patch 8.2.2681: Vim9: test fails for redeclaring script variable Commit: https://github.com/vim/vim/commit/12be734faffe1da04dfa9098e73abaa864204bc5 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 31 21:47:33 2021 +0200 patch 8.2.2681: Vim9: test fails for redeclaring script variable Problem: Vim9: test fails for redeclaring script variable. Solution: It's OK to assign to an existing script variable in legacy.
author Bram Moolenaar <Bram@vim.org>
date Wed, 31 Mar 2021 22:00:03 +0200
parents 8ab83d4f5d2e
children 3c0286cbdea6
files src/evalvars.c src/version.c
diffstat 2 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -3219,16 +3219,17 @@ set_var_const(
 		goto failed;
 	    }
 
+	    if (is_script_local && vim9script
+			      && (flags & (ASSIGN_NO_DECL | ASSIGN_DECL)) == 0)
+	    {
+		semsg(_(e_redefining_script_item_str), name);
+		goto failed;
+	    }
+
 	    if (var_in_vim9script)
 	    {
 		where_T where;
 
-		if ((flags & (ASSIGN_NO_DECL | ASSIGN_DECL)) == 0)
-		{
-		    semsg(_(e_redefining_script_item_str), name);
-		    goto failed;
-		}
-
 		// check the type and adjust to bool if needed
 		where.wt_index = var_idx;
 		where.wt_variable = TRUE;
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2681,
+/**/
     2680,
 /**/
     2679,