]> granicus.if.org Git - vim/commitdiff
patch 8.2.3859: Vim9: some code lines not tested v8.2.3859
authorBram Moolenaar <Bram@vim.org>
Mon, 20 Dec 2021 12:25:03 +0000 (12:25 +0000)
committerBram Moolenaar <Bram@vim.org>
Mon, 20 Dec 2021 12:25:03 +0000 (12:25 +0000)
Problem:    Vim9: some code lines not tested.
Solution:   Add a few specific tests.

src/errors.h
src/testdir/test_vim9_cmd.vim
src/testdir/test_vim9_script.vim
src/version.c
src/vim9compile.c

index 31f275d17111f8ee54b49be6ed1971a5faa8f964..8d8a2ca9a3e156f1e689d828a3060325af35db49 100644 (file)
@@ -850,3 +850,5 @@ EXTERN char e_string_list_or_blob_required_for_argument_nr[]
        INIT(= N_("E1252: String, List or Blob required for argument %d"));
 EXTERN char e_string_expected_for_argument_nr[]
        INIT(= N_("E1253: String expected for argument %d"));
+EXTERN char e_cannot_use_script_variable_in_for_loop[]
+       INIT(= N_("E1254: Cannot use script variable in for loop"));
index 2d86b6ba3b6e03db024d31c97ae1d76b819239af..6347a282a6795c0939895e7857dfcd2a054bbd37 100644 (file)
@@ -1392,6 +1392,10 @@ def Test_lockvar()
   s:theList[1] = 44
   assert_equal([1, 44, 3], s:theList)
 
+  if 0
+    lockvar whatever
+  endif
+
   var d = {a: 1, b: 2}
   d.a = 3
   d.b = 4
index af80935ab9b74efc2b921792dcf2ea4b43edfffc..fe985de35c3ca4edf8604227a7e297a26423b194 100644 (file)
@@ -2963,7 +2963,7 @@ enddef
 
 def Test_for_loop_script_var()
   # cannot use s:var in a :def function
-  CheckDefFailure(['for s:var in range(3)', 'echo 3'], 'E461:')
+  CheckDefFailure(['for s:var in range(3)', 'echo 3'], 'E1254:')
 
   # can use s:var in Vim9 script, with or without s:
   var lines =<< trim END
index a7f372dd620e8b5bd9d69f63be08591d03ddf64a..38c9e0098dd142dd0ea33fe2343a3a230888c2a3 100644 (file)
@@ -749,6 +749,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3859,
 /**/
     3858,
 /**/
index 2b27f514cddfe77fa216461bb11643418af9162f..4bce9972d28c876a07b0cbddb77b9ad807fde75d 100644 (file)
@@ -8333,7 +8333,6 @@ compile_for(char_u *arg_start, cctx_T *cctx)
                lhs_type = parse_type(&p, cctx->ctx_type_list, TRUE);
            }
 
-           // Script var is not supported.
            if (get_var_dest(name, &dest, CMD_for, &opt_flags,
                                              &vimvaridx, &type, cctx) == FAIL)
                goto failed;
@@ -8351,17 +8350,18 @@ compile_for(char_u *arg_start, cctx_T *cctx)
            }
            else
            {
-               if (!valid_varname(arg, (int)varlen, FALSE))
-                   goto failed;
-               if (lookup_local(arg, varlen, NULL, cctx) == OK)
+               // Script var is not supported.
+               if (STRNCMP(name, "s:", 2) == 0)
                {
-                   semsg(_(e_variable_already_declared), arg);
+                   emsg(_(e_cannot_use_script_variable_in_for_loop));
                    goto failed;
                }
 
-               if (STRNCMP(name, "s:", 2) == 0)
+               if (!valid_varname(arg, (int)varlen, FALSE))
+                   goto failed;
+               if (lookup_local(arg, varlen, NULL, cctx) == OK)
                {
-                   semsg(_(e_cannot_declare_script_variable_in_function), name);
+                   semsg(_(e_variable_already_declared), arg);
                    goto failed;
                }