]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1611: v:maxcol can be changed in a :for loop v9.0.1611
authorBram Moolenaar <Bram@vim.org>
Mon, 5 Jun 2023 18:46:18 +0000 (19:46 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 5 Jun 2023 18:46:18 +0000 (19:46 +0100)
Problem:    v:maxcol can be changed in a :for loop.
Solution:   Check for read-only loop variable. (closes #12470)

src/evalvars.c
src/testdir/test_eval_stuff.vim
src/version.c

index bebee2a5bcf802f70d6c1ae7d1927c9506126344..35a1d20831b8196c76d157423462f8584deeb2f8 100644 (file)
@@ -3842,7 +3842,8 @@ set_var_const(
            }
 
            if ((flags & ASSIGN_FOR_LOOP) == 0
-                                && var_check_permission(di, name) == FAIL)
+                                ? var_check_permission(di, name) == FAIL
+                                : var_check_ro(di->di_flags, name, FALSE))
                goto failed;
        }
        else
index 46ec12df16a639a6aa7307f1c5488d1ee5ec9748..a346399eb513bbf2c45a4c98f5d823d206e7edbc 100644 (file)
@@ -126,6 +126,7 @@ func Test_for_invalid()
   call assert_fails("for x in 99", 'E1098:')
   call assert_fails("for x in function('winnr')", 'E1098:')
   call assert_fails("for x in {'a': 9}", 'E1098:')
+  call assert_fails("for v:maxcol in range(1)", 'E46:')
 
   if 0
     /1/5/2/s/\n
index a8f21046987f2e3574cb4fcaae57996340e7c1ed..2e3c240f6e849212e0c1432b395c1847f8f2645a 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1611,
 /**/
     1610,
 /**/