]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2283: Vim9: crash when lambda has fewer arguments than expected v8.2.2283
authorBram Moolenaar <Bram@vim.org>
Sun, 3 Jan 2021 12:09:51 +0000 (13:09 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 3 Jan 2021 12:09:51 +0000 (13:09 +0100)
Problem:    Vim9: crash when lambda has fewer arguments than expected.
Solution:   Don't check arguments when already failed. (closes #7606)

src/testdir/test_vim9_func.vim
src/version.c
src/vim9type.c

index 20ad3ba8e4e02fea74b69095f69caf1768fdedf9..251790bc5710e20aa2465c8fccb9595a84380a47 100644 (file)
@@ -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()
index ed0b10236b31afeaeef63e8b88e76916c0d3b635..30eac83f886e0b968530dcc4d63811bf20c385e1 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2283,
 /**/
     2282,
 /**/
index d2dbc768c8388d514527fca7f032def0c8e7e20f..2344874a33f09548463003b98ec150d7111baf4c 100644 (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 < 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;