# HG changeset patch # User Bram Moolenaar # Date 1607184903 -3600 # Node ID b6aadb0b3a56d2e4e63abaf6749cb206e666b72c # Parent 211188403293395a070418c0a3bf3cd6df768882 patch 8.2.2094: when an expression fails getting next command may be wrong Commit: https://github.com/vim/vim/commit/d0fe620cbbf5f5e00446efa89893036265c5c302 Author: Bram Moolenaar Date: Sat Dec 5 17:11:12 2020 +0100 patch 8.2.2094: when an expression fails getting next command may be wrong Problem: When an expression fails getting the next command may be wrong. Solution: Do not check for a next command after :eval fails. (closes https://github.com/vim/vim/issues/7415) diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -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) diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -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() diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2094, +/**/ 2093, /**/ 2092,