Skip to content

Commit c7dac85

Browse files
committed
patch 8.2.2528: Vim9: crash when compiling lambda fails
Problem: Vim9: crash when compiling lambda fails. Solution: Bail out after compilation fails. (closes #7862)
1 parent 0640950 commit c7dac85

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/eval.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3428,8 +3428,12 @@ eval7(
34283428
ufunc_T *ufunc = rettv->vval.v_partial->pt_func;
34293429

34303430
// compile it here to get the return type
3431-
compile_def_function(ufunc,
3432-
TRUE, PROFILING(ufunc), NULL);
3431+
if (compile_def_function(ufunc,
3432+
TRUE, PROFILING(ufunc), NULL) == FAIL)
3433+
{
3434+
clear_tv(rettv);
3435+
ret = FAIL;
3436+
}
34333437
}
34343438
}
34353439
if (ret == NOTDONE)

src/testdir/test_vim9_assign.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,11 @@ def Test_assign_lambda()
11181118
Ref = (j) => !j
11191119
END
11201120
CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(any): bool')
1121+
1122+
lines =<< trim END
1123+
echo filter([1, 2, 3], (_, v: string) => v + 1)
1124+
END
1125+
CheckDefAndScriptFailure(lines, 'E1051:')
11211126
enddef
11221127

11231128
def Test_heredoc()

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+
2528,
753755
/**/
754756
2527,
755757
/**/

0 commit comments

Comments
 (0)