0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.2283: Vim9: crash when lambda has fewer arguments than expected

Problem:    Vim9: crash when lambda has fewer arguments than expected.
Solution:   Don't check arguments when already failed. (closes #7606)
This commit is contained in:
Bram Moolenaar
2021-01-03 13:09:51 +01:00
parent 339c1bdbdf
commit e68b02a1c4
3 changed files with 17 additions and 2 deletions

View File

@@ -554,6 +554,18 @@ def Test_call_lambda_args()
echo Ref(1, 'x') echo Ref(1, 'x')
END END
CheckDefFailure(lines, 'E1013: Argument 2: type mismatch, expected number but got string') CheckDefFailure(lines, 'E1013: Argument 2: type mismatch, expected number but got string')
lines =<< trim END
var Ref: func(job, string, number)
Ref = (x, y) => 0
END
CheckDefAndScriptFailure(lines, 'E1012:')
lines =<< trim END
var Ref: func(job, string)
Ref = (x, y, z) => 0
END
CheckDefAndScriptFailure(lines, 'E1012:')
enddef enddef
def Test_lambda_uses_assigned_var() def Test_lambda_uses_assigned_var()

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2283,
/**/ /**/
2282, 2282,
/**/ /**/

View File

@@ -490,8 +490,9 @@ check_type(type_T *expected, type_T *actual, int give_msg, int argidx)
&& actual->tt_argcount != -1 && actual->tt_argcount != -1
&& (actual->tt_argcount < expected->tt_min_argcount && (actual->tt_argcount < expected->tt_min_argcount
|| actual->tt_argcount > expected->tt_argcount)) || actual->tt_argcount > expected->tt_argcount))
ret = FAIL; ret = FAIL;
if (expected->tt_args != NULL && actual->tt_args != NULL) if (ret == OK && expected->tt_args != NULL
&& actual->tt_args != NULL)
{ {
int i; int i;