]> granicus.if.org Git - vim/commitdiff
patch 8.2.0283: Vim9: failing to load script var not tested v8.2.0283
authorBram Moolenaar <Bram@vim.org>
Wed, 19 Feb 2020 19:23:11 +0000 (20:23 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 19 Feb 2020 19:23:11 +0000 (20:23 +0100)
Problem:    Vim9: failing to load script var not tested.
Solution:   Add more tests.   Fix using s: in old script.

src/testdir/test_vim9_expr.vim
src/testdir/test_vim9_script.vim
src/version.c
src/vim9compile.c

index 235aee2105e51e3b45d8775b5d321dfb77fb456a..1b04d02781bec6da8b0d520d1e8c83fcb03f1ae3 100644 (file)
@@ -726,6 +726,9 @@ func Test_expr7_fails()
 
   call CheckDefFailure("let x = &notexist", 'E113:')
   call CheckDefExecFailure("&grepprg = [343]", 'E1051:')
+
+  call CheckDefExecFailure("echo s:doesnt_exist", 'E121:')
+  call CheckDefExecFailure("echo g:doesnt_exist", 'E121:')
 endfunc
 
 let g:Funcrefs = [function('add')]
index 0e18e4a1b6c98230785cc1cff09a7868c95af7fe..1fb08ab7e88f8e0e7f092de002982129598e211b 100644 (file)
@@ -61,10 +61,10 @@ def Test_assignment()
   assert_equal('foobar', $ENVVAR)
   $ENVVAR = ''
 
-  appendToMe ..= 'yyy'
-  assert_equal('xxxyyy', appendToMe)
-  addToMe += 222
-  assert_equal(333, addToMe)
+  s:appendToMe ..= 'yyy'
+  assert_equal('xxxyyy', s:appendToMe)
+  s:addToMe += 222
+  assert_equal(333, s:addToMe)
 enddef
 
 func Test_assignment_failure()
index f964607cdaeb2315facf914eeb045b668df1323f..f97c50595b73921fbc2444ccbbc05af071975255 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    283,
 /**/
     282,
 /**/
index 8614943fd4b818b31a14748d30c595d35f080597..7fe27642af7a7f4c3f2a15d6f949f2b3341215d9 100644 (file)
@@ -1513,9 +1513,9 @@ compile_load_scriptvar(cctx_T *cctx, char_u *name)
     int                    idx = get_script_item_idx(current_sctx.sc_sid, name, FALSE);
     imported_T     *import;
 
-    if (idx == -1)
+    if (idx == -1 || si->sn_version != SCRIPT_VERSION_VIM9)
     {
-       // variable exists but is not in sn_var_vals: old style script.
+       // variable is not in sn_var_vals: old style script.
        return generate_OLDSCRIPT(cctx, ISN_LOADS, name, current_sctx.sc_sid,
                                                                       &t_any);
     }
@@ -1627,7 +1627,9 @@ compile_load(char_u **arg, char_u *end, cctx_T *cctx, int error)
                        || (len == 5 && STRNCMP("false", *arg, 5) == 0))
                    res = generate_PUSHBOOL(cctx, **arg == 't'
                                                     ? VVAL_TRUE : VVAL_FALSE);
-               else
+               else if (SCRIPT_ITEM(current_sctx.sc_sid)->sn_version
+                                                       == SCRIPT_VERSION_VIM9)
+                   // in Vim9 script "var" can be script-local.
                   res = compile_load_scriptvar(cctx, name);
            }
        }