Skip to content

Commit d0fe620

Browse files
committed
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 #7415)
1 parent c0913d0 commit d0fe620

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/eval.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,10 @@ eval0(
21562156
&& called_emsg == called_emsg_before
21572157
&& (flags & EVAL_CONSTANT) == 0)
21582158
semsg(_(e_invexpr2), arg);
2159-
ret = FAIL;
2159+
2160+
// Some of the expression may not have been consumed. Do not check for
2161+
// a next command to avoid more errors.
2162+
return FAIL;
21602163
}
21612164

21622165
if (eap != NULL)

src/testdir/test_vim9_cmd.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,19 @@ def Test_eval_command()
558558
->Increment()
559559
assert_equal(111 + 3 + 4 + 5, g:val)
560560
unlet g:val
561+
562+
var lines =<< trim END
563+
vim9script
564+
g:caught = 'no'
565+
try
566+
eval 123 || 0
567+
catch
568+
g:caught = 'yes'
569+
endtry
570+
assert_equal('yes', g:caught)
571+
unlet g:caught
572+
END
573+
CheckScriptSuccess(lines)
561574
enddef
562575

563576
def Test_map_command()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2094,
753755
/**/
754756
2093,
755757
/**/

0 commit comments

Comments
 (0)