diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-01-03 13:09:51 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-01-03 13:09:51 +0100 |
commit | e68b02a1c40388bbb85e7b825bc538298963e1e1 (patch) | |
tree | 48159cea5923224348fb9631538864623b83a317 | |
parent | 339c1bdbdfb823c4ea36242f0a4f083cbc010b84 (diff) | |
download | vim-git-e68b02a1c40388bbb85e7b825bc538298963e1e1.tar.gz |
patch 8.2.2283: Vim9: crash when lambda has fewer arguments than expectedv8.2.2283
Problem: Vim9: crash when lambda has fewer arguments than expected.
Solution: Don't check arguments when already failed. (closes #7606)
-rw-r--r-- | src/testdir/test_vim9_func.vim | 12 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9type.c | 5 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 20ad3ba8e..251790bc5 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -554,6 +554,18 @@ def Test_call_lambda_args() echo Ref(1, 'x') END 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 def Test_lambda_uses_assigned_var() diff --git a/src/version.c b/src/version.c index ed0b10236..30eac83f8 100644 --- 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 */ /**/ + 2283, +/**/ 2282, /**/ 2281, diff --git a/src/vim9type.c b/src/vim9type.c index d2dbc768c..2344874a3 100644 --- a/src/vim9type.c +++ b/src/vim9type.c @@ -490,8 +490,9 @@ check_type(type_T *expected, type_T *actual, int give_msg, int argidx) && actual->tt_argcount != -1 && (actual->tt_argcount < expected->tt_min_argcount || actual->tt_argcount > expected->tt_argcount)) - ret = FAIL; - if (expected->tt_args != NULL && actual->tt_args != NULL) + ret = FAIL; + if (ret == OK && expected->tt_args != NULL + && actual->tt_args != NULL) { int i; |