]> granicus.if.org Git - vim/commitdiff
patch 8.2.4314: test fails where lines are skipped v8.2.4314
authorBram Moolenaar <Bram@vim.org>
Sun, 6 Feb 2022 20:28:13 +0000 (20:28 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 6 Feb 2022 20:28:13 +0000 (20:28 +0000)
Problem:    Test fails where lines are skipped.
Solution:   Only give an error when not skipping commands.

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

index 4fa71d94deefbdb0f5a7327e32290ffbe0619b27..37459a76bc4df39d3265a2d80081b7489f7af702 100644 (file)
@@ -1228,6 +1228,11 @@ def Test_vim9script_fails()
 
   assert_fails('vim9script', 'E1038:')
   v9.CheckDefFailure(['vim9script'], 'E1038:')
+
+  # no error when skipping
+  if has('nothing')
+    vim9script
+  endif
 enddef
 
 def Test_script_var_shadows_function()
index 7dbefa49f82f782eb2d61c14f81e57196db19afe..a071c5f678569ea14f5ea3be9607c28d58bc84e4 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4314,
 /**/
     4313,
 /**/
index 0bf47e24d98d2f0a5e594c33184081154070d0d8..d0479a5fbd9ec2bcad27156b99e7375d19a9b083 100644 (file)
@@ -3139,8 +3139,13 @@ compile_def_function(
                    break;
 
            case CMD_vim9script:
-                   emsg(_(e_vim9script_can_only_be_used_in_script));
-                   goto erret;
+                   if (cctx.ctx_skip != SKIP_YES)
+                   {
+                       emsg(_(e_vim9script_can_only_be_used_in_script));
+                       goto erret;
+                   }
+                   line = (char_u *)"";
+                   break;
 
            case CMD_global:
                    if (check_global_and_subst(ea.cmd, p) == FAIL)