# HG changeset patch # User Bram Moolenaar # Date 1613584804 -3600 # Node ID a620df0ebbe55f357f374d1b2b940b384be1d7b7 # Parent 275505319b8005a14fce93a0055cff651f1c3c74 patch 8.2.2528: Vim9: crash when compiling lambda fails Commit: https://github.com/vim/vim/commit/c7dac8534ee7f7a49e9d7a37330397c64455cdd7 Author: Bram Moolenaar Date: Wed Feb 17 18:49:11 2021 +0100 patch 8.2.2528: Vim9: crash when compiling lambda fails Problem: Vim9: crash when compiling lambda fails. Solution: Bail out after compilation fails. (closes https://github.com/vim/vim/issues/7862) diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -3428,8 +3428,12 @@ eval7( ufunc_T *ufunc = rettv->vval.v_partial->pt_func; // compile it here to get the return type - compile_def_function(ufunc, - TRUE, PROFILING(ufunc), NULL); + if (compile_def_function(ufunc, + TRUE, PROFILING(ufunc), NULL) == FAIL) + { + clear_tv(rettv); + ret = FAIL; + } } } if (ret == NOTDONE) diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -1118,6 +1118,11 @@ def Test_assign_lambda() Ref = (j) => !j END CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(any): bool') + + lines =<< trim END + echo filter([1, 2, 3], (_, v: string) => v + 1) + END + CheckDefAndScriptFailure(lines, 'E1051:') enddef def Test_heredoc() 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 */ /**/ + 2528, +/**/ 2527, /**/ 2526,