]> granicus.if.org Git - vim/commitdiff
patch 8.2.2094: when an expression fails getting next command may be wrong v8.2.2094
authorBram Moolenaar <Bram@vim.org>
Sat, 5 Dec 2020 16:11:12 +0000 (17:11 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 5 Dec 2020 16:11:12 +0000 (17:11 +0100)
Problem:    When an expression fails getting the next command may be wrong.
Solution:   Do not check for a next command after :eval fails. (closes #7415)

src/eval.c
src/testdir/test_vim9_cmd.vim
src/version.c

index 223251090deddac005929c34fda3a2cba72e0457..47aaaad237b506c101df7e9d3b00002fdba98c0f 100644 (file)
@@ -2156,7 +2156,10 @@ eval0(
                && called_emsg == called_emsg_before
                && (flags & EVAL_CONSTANT) == 0)
            semsg(_(e_invexpr2), arg);
-       ret = FAIL;
+
+       // Some of the expression may not have been consumed.  Do not check for
+       // a next command to avoid more errors.
+       return FAIL;
     }
 
     if (eap != NULL)
index 162d79508d07748af861037ae42ef7dfd7226534..37fc559bf07dbd4861565c746d920b7113411b9e 100644 (file)
@@ -558,6 +558,19 @@ def Test_eval_command()
         ->Increment()
   assert_equal(111 + 3 + 4 + 5, g:val)
   unlet g:val
+
+  var lines =<< trim END
+    vim9script
+    g:caught = 'no'
+    try
+      eval 123 || 0
+    catch
+      g:caught = 'yes'
+    endtry
+    assert_equal('yes', g:caught)
+    unlet g:caught
+  END
+  CheckScriptSuccess(lines)
 enddef
 
 def Test_map_command()
index b28638b44692e9626b2a9ae48cbf8296c3317109..a0bf9363c2df4bee198e4265bd350c869aebca56 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2094,
 /**/
     2093,
 /**/