diff src/evalvars.c @ 20842:bacc2ab11810 v8.2.0973

patch 8.2.0973: Vim9: type is not checked when assigning to a script variable Commit: https://github.com/vim/vim/commit/34db91f7a47b7bd4aabf1e1dfbaa8a08278bf78d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 13 19:00:10 2020 +0200 patch 8.2.0973: Vim9: type is not checked when assigning to a script variable Problem: Vim9: type is not checked when assigning to a script variable. Solution: Check the type.
author Bram Moolenaar <Bram@vim.org>
date Sat, 13 Jun 2020 19:15:03 +0200
parents 0600ab7b9f09
children 876e16c48bd1
line wrap: on
line diff
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -2883,12 +2883,17 @@ set_var_const(
 			       || var_check_lock(di->di_tv.v_lock, name, FALSE))
 		return;
 
-	    if ((flags & LET_NO_COMMAND) == 0
-		    && is_script_local
-		    && current_sctx.sc_version == SCRIPT_VERSION_VIM9)
+	    if (is_script_local
+			     && current_sctx.sc_version == SCRIPT_VERSION_VIM9)
 	    {
-		semsg(_("E1041: Redefining script item %s"), name);
-		return;
+		if ((flags & LET_NO_COMMAND) == 0)
+		{
+		    semsg(_("E1041: Redefining script item %s"), name);
+		    return;
+		}
+
+		// check the type
+		check_script_var_type(&di->di_tv, tv, name);
 	    }
 	}
 	else