]> granicus.if.org Git - vim/commitdiff
patch 8.2.0611: Vim9: no check for space before #comment v8.2.0611
authorBram Moolenaar <Bram@vim.org>
Mon, 20 Apr 2020 15:46:14 +0000 (17:46 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 20 Apr 2020 15:46:14 +0000 (17:46 +0200)
Problem:    Vim9: no check for space before #comment.
Solution:   Add space checks.

src/eval.c
src/evalvars.c
src/ex_docmd.c
src/testdir/test_vim9_script.vim
src/version.c

index 94ecf936e428180c3c7cd67c0f6345d08e6796ec..43c20086c2b22e2e1ebca4cb5a4fa632825163a9 100644 (file)
@@ -1773,7 +1773,7 @@ eval0(
 
     p = skipwhite(arg);
     ret = eval1(&p, rettv, evaluate);
-    if (ret == FAIL || !ends_excmd(*p))
+    if (ret == FAIL || !ends_excmd2(arg, p))
     {
        if (ret != FAIL)
            clear_tv(rettv);
index b5075d59cc69e8d47309880a1f462730b589fbba..1d0599f5ae05db0482ffb1488fa1bc68dd547dca 100644 (file)
@@ -737,7 +737,7 @@ ex_let_const(exarg_T *eap, int is_const)
            emsg(_(e_invarg));
        else if (expr[0] == '.')
            emsg(_("E985: .= is not supported with script version 2"));
-       else if (!ends_excmd(*arg))
+       else if (!ends_excmd2(eap->cmd, arg))
            // ":let var1 var2"
            arg = list_arg_vars(eap, arg, &first);
        else if (!eap->skip)
@@ -1068,7 +1068,7 @@ list_arg_vars(exarg_T *eap, char_u *arg, int *first)
     char_u     *tofree;
     typval_T    tv;
 
-    while (!ends_excmd(*arg) && !got_int)
+    while (!ends_excmd2(eap->cmd, arg) && !got_int)
     {
        if (error || eap->skip)
        {
index e2d771e194dbc63d446c909fc2fcc19c30f47644..43cd013e2cf540821d53a7781cbe91d3b80aa658 100644 (file)
@@ -7903,7 +7903,7 @@ ex_findpat(exarg_T *eap)
            p = skipwhite(p);
 
            // Check for trailing illegal characters
-           if (!ends_excmd(*p))
+           if (!ends_excmd2(eap->arg, p))
                eap->errmsg = e_trailing;
            else
                eap->nextcmd = check_nextcmd(p);
index 4b7339961f68f032d4fada28a6f1869665ae376e..70653f0332512b0fcf3d91a17b78d1b25ece5532 100644 (file)
@@ -1208,6 +1208,69 @@ def Test_vim9_comment_not_compiled()
       'let g:var = 123',
       'unlet g:var # something',
       ], 'E488:')
+
+  CheckScriptSuccess([
+      'vim9script',
+      'if 1 # comment',
+      '  echo "yes"',
+      'elseif 2 #comment',
+      '  echo "no"',
+      'endif',
+      ])
+
+  CheckScriptFailure([
+      'vim9script',
+      'if 1# comment',
+      '  echo "yes"',
+      'endif',
+      ], 'E15:')
+
+  CheckScriptFailure([
+      'vim9script',
+      'if 0 # comment',
+      '  echo "yes"',
+      'elseif 2#comment',
+      '  echo "no"',
+      'endif',
+      ], 'E15:')
+
+  CheckScriptSuccess([
+      'vim9script',
+      'let # comment',
+      ])
+
+  CheckScriptFailure([
+      'vim9script',
+      'let# comment',
+      ], 'E121:')
+
+  CheckScriptSuccess([
+      'vim9script',
+      'let v:version # comment',
+      ])
+
+  CheckScriptFailure([
+      'vim9script',
+      'let v:version# comment',
+      ], 'E121:')
+
+  CheckScriptSuccess([
+      'vim9script',
+      'new'
+      'call setline(1, ["# define pat", "last"])',
+      '$',
+      'dsearch /pat/ #comment',
+      'bwipe!',
+      ])
+
+  CheckScriptFailure([
+      'vim9script',
+      'new'
+      'call setline(1, ["# define pat", "last"])',
+      '$',
+      'dsearch /pat/#comment',
+      'bwipe!',
+      ], 'E488:')
 enddef
 
 " Keep this last, it messes up highlighting.
index 1c5ad56246e26932ebe29bbb924f75b7e43b2bc8..d051d79c8d16c56e2682e119012da4733c6f8b6c 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    611,
 /**/
     610,
 /**/