]> granicus.if.org Git - vim/commitdiff
patch 8.2.2528: Vim9: crash when compiling lambda fails v8.2.2528
authorBram Moolenaar <Bram@vim.org>
Wed, 17 Feb 2021 17:49:11 +0000 (18:49 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 17 Feb 2021 17:49:11 +0000 (18:49 +0100)
Problem:    Vim9: crash when compiling lambda fails.
Solution:   Bail out after compilation fails. (closes #7862)

src/eval.c
src/testdir/test_vim9_assign.vim
src/version.c

index 785d8417a46731ff417ac71fb0e5413858a094ea..444c0faf388d1c27d52503f87ac99bfc424eb368 100644 (file)
@@ -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)
index 4c63217f26aa443dba155a0713b3c8085101ee97..392a091a1a0712b818c1ea9a258b7aa4cffb1153 100644 (file)
@@ -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()
index 0fb889621df0fbb8125d8bd01f74eedab429e51f..4c0fb5c1e5bd8070d4f1632002c055ac1a81b498 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2528,
 /**/
     2527,
 /**/