]> granicus.if.org Git - vim/commitdiff
patch 9.0.0869: bogus error when string used after :elseif v9.0.0869
authorBram Moolenaar <Bram@vim.org>
Sat, 12 Nov 2022 23:12:55 +0000 (23:12 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 12 Nov 2022 23:12:55 +0000 (23:12 +0000)
Problem:    Bogus error when string used after :elseif.
Solution:   Do not consider a double quote the start of a comment.
            (closes #11534)

src/ex_eval.c
src/testdir/test_vimscript.vim
src/version.c

index e1c28899e1b5a244dc32baa91905c61f190191b9..68dc6d78ca6e917073abad074ff0c9cb490aa235 100644 (file)
@@ -1173,7 +1173,8 @@ ex_else(exarg_T *eap)
     {
        // When skipping we ignore most errors, but a missing expression is
        // wrong, perhaps it should have been "else".
-       if (skip && ends_excmd(*eap->arg))
+       // A double quote here is the start of a string, not a comment.
+       if (skip && *eap->arg != '"' && ends_excmd(*eap->arg))
            semsg(_(e_invalid_expression_str), eap->arg);
        else
            result = eval_to_bool(eap->arg, &error, eap, skip, FALSE);
index 4aa6bca92641d6b597584269fde46cf4054402d5..a23bac3d3e3f5b895e1fdec2d87dbfe17a339140 100644 (file)
@@ -192,6 +192,16 @@ func Test_if_while()
     call assert_equal('ab3j3b2c2b1f1h1km', g:Xpath)
 endfunc
 
+" Check double quote after skipped "elseif" does not give error E15
+func Test_skipped_elseif()
+  if "foo" ==? "foo"
+      let result = "first"
+  elseif "foo" ==? "foo"
+      let result = "second"
+  endif
+  call assert_equal('first', result)
+endfunc
+
 "-------------------------------------------------------------------------------
 " Test 4:   :return                                                        {{{1
 "-------------------------------------------------------------------------------
index b16f86040aaf26e161d5a8355edb539ad5516b1b..10aa6dedcc3aad47c3a050b9126fbd83cc58b8ab 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    869,
 /**/
     868,
 /**/