]> granicus.if.org Git - vim/commitdiff
patch 8.2.2693: Vim9: locked script variable can be changed v8.2.2693
authorBram Moolenaar <Bram@vim.org>
Fri, 2 Apr 2021 12:44:02 +0000 (14:44 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 2 Apr 2021 12:44:02 +0000 (14:44 +0200)
Problem:    Vim9: locked script variable can be changed.
Solution:   Check legacy script variable for being locked. (issue #8031)

src/testdir/test_vim9_assign.vim
src/version.c
src/vim9execute.c

index c06205225d99a97ad136da0f147f2eb185efe58e..867afaf7159ac0d950b30ce0e5055ebadea95037 100644 (file)
@@ -1355,7 +1355,17 @@ def Test_var_declaration_fails()
     enddef
     SetLocked()
   END
-  CheckScriptFailure(lines, 'E741: Value is locked: name')
+  CheckScriptFailure(lines, 'E741: Value is locked: name', 1)
+
+  lines =<< trim END
+    let s:legacy = 'one'
+    lockvar s:legacy
+    def SetLocked()
+      s:legacy = 'two'
+    enddef
+    call SetLocked()
+  END
+  CheckScriptFailure(lines, 'E741: Value is locked: s:legacy', 1)
 
   lines =<< trim END
     vim9script
@@ -1365,7 +1375,7 @@ def Test_var_declaration_fails()
     SetGlobalConst()
     g:globConst = 234
   END
-  CheckScriptFailure(lines, 'E741: Value is locked: globConst')
+  CheckScriptFailure(lines, 'E741: Value is locked: globConst', 1)
   unlet g:globConst
 
   lines =<< trim END
index 1059585008a36e3e5d902752ad24b007c99dcdf8..760a0f48eb81f839df659a1de1d8b67259dba8aa 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2693,
 /**/
     2692,
 /**/
index 69254bebeebdfca85f3d90aeadcd33e7f1682304..81041bbeae137a09c8fbcb5b9683796c21654d34 100644 (file)
@@ -1942,6 +1942,9 @@ call_def_function(
                        store_var(name, STACK_TV_BOT(0));
                    else
                    {
+                       SOURCING_LNUM = iptr->isn_lnum;
+                       if (var_check_permission(di, name) == FAIL)
+                           goto on_error;
                        clear_tv(&di->di_tv);
                        di->di_tv = *STACK_TV_BOT(0);
                    }