diff src/evalvars.c @ 21610:586241ee8096 v8.2.1355

patch 8.2.1355: Vim9: no error using :let for options and registers Commit: https://github.com/vim/vim/commit/c2ee44cc382d4b097f51ea3251f00fb35493ea4f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 2 16:59:00 2020 +0200 patch 8.2.1355: Vim9: no error using :let for options and registers Problem: Vim9: no error using :let for options and registers. Solution: Give an error. (closes https://github.com/vim/vim/issues/6568)
author Bram Moolenaar <Bram@vim.org>
date Sun, 02 Aug 2020 17:00:06 +0200
parents 4e679db1c404
children 3c6c52fbc8ea
line wrap: on
line diff
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -1219,6 +1219,13 @@ ex_let_one(
     int		opt_flags;
     char_u	*tofree = NULL;
 
+    if (in_vim9script() && (flags & LET_NO_COMMAND) == 0
+				  && vim_strchr((char_u *)"$@&", *arg) != NULL)
+    {
+	vim9_declare_error(arg);
+	return NULL;
+    }
+
     // ":let $VAR = expr": Set environment variable.
     if (*arg == '$')
     {
@@ -1227,11 +1234,6 @@ ex_let_one(
 	    emsg(_("E996: Cannot lock an environment variable"));
 	    return NULL;
 	}
-	if (in_vim9script() && (flags & LET_NO_COMMAND) == 0)
-	{
-	    vim9_declare_error(arg);
-	    return NULL;
-	}
 
 	// Find the end of the name.
 	++arg;
@@ -2427,7 +2429,7 @@ eval_variable(
 	    else
 	    {
 		scriptitem_T    *si = SCRIPT_ITEM(import->imp_sid);
-		svar_T	    *sv = ((svar_T *)si->sn_var_vals.ga_data)
+		svar_T		*sv = ((svar_T *)si->sn_var_vals.ga_data)
 						    + import->imp_var_vals_idx;
 		tv = sv->sv_tv;
 	    }