diff src/vim9compile.c @ 21937:b931df03adcc v8.2.1518

patch 8.2.1518: Vim9: cannot assign to local option Commit: https://github.com/vim/vim/commit/2e80095501238e0c6b702ac7cdfa2e2b763dba28 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 23 19:34:48 2020 +0200 patch 8.2.1518: Vim9: cannot assign to local option Problem: Vim9: cannot assign to local option. Solution: Skip over "&l:" and "&g:". (closes https://github.com/vim/vim/issues/6749)
author Bram Moolenaar <Bram@vim.org>
date Sun, 23 Aug 2020 19:45:03 +0200
parents 8e09827f8bac
children 4343657b49fa
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -4550,8 +4550,8 @@ compile_assignment(char_u *arg, exarg_T 
 	    p = var_start + 2;
 	else
 	{
-	    p = (*var_start == '&' || *var_start == '$')
-						   ? var_start + 1 : var_start;
+	    // skip over the leading "&", "&l:", "&g:" and "$"
+	    p = skip_option_env_lead(var_start);
 	    p = to_name_end(p, TRUE);
 	}
 
@@ -4595,8 +4595,8 @@ compile_assignment(char_u *arg, exarg_T 
 		}
 		cc = *p;
 		*p = NUL;
-		opt_type = get_option_value(var_start + 1, &numval,
-							      NULL, opt_flags);
+		opt_type = get_option_value(skip_option_env_lead(var_start),
+						     &numval, NULL, opt_flags);
 		*p = cc;
 		if (opt_type == -3)
 		{
@@ -5131,7 +5131,8 @@ compile_assignment(char_u *arg, exarg_T 
 	    switch (dest)
 	    {
 		case dest_option:
-		    generate_STOREOPT(cctx, name + 1, opt_flags);
+		    generate_STOREOPT(cctx, skip_option_env_lead(name),
+								    opt_flags);
 		    break;
 		case dest_global:
 		    // include g: with the name, easier to execute that way