]> granicus.if.org Git - vim/commitdiff
patch 8.2.2965: Vim9: crash when calling function that failed to compile v8.2.2965
authorBram Moolenaar <Bram@vim.org>
Tue, 8 Jun 2021 20:01:53 +0000 (22:01 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 8 Jun 2021 20:01:53 +0000 (22:01 +0200)
Problem:    Vim9: crash when calling function that failed to compile.
Solution:   Fail when trying to call the function. (closes #8344)

src/errors.h
src/testdir/test_vim9_func.vim
src/version.c
src/vim9compile.c

index 94a752ae681fef5019ebf08271cfbd828f396ec1..fac3e26d8b6239268c585e7aa100a311b8e99995 100644 (file)
@@ -423,3 +423,5 @@ EXTERN char e_one_argument_too_few[]
        INIT(= N_("E1190: One argument too few"));
 EXTERN char e_nr_arguments_too_few[]
        INIT(= N_("E1190: %d arguments too few"));
+EXTERN char e_call_to_function_that_failed_to_compile_str[]
+       INIT(= N_("E1191: Call to function that failed to compile: %s"));
index 7e21b37883668d3fb0fd59f5750583023d77321b..cd2a15d2da9b55b9c9ffe3c644d48584d344bd4a 100644 (file)
@@ -74,6 +74,22 @@ def TestCompilingErrorInTry()
   delete('Xdir', 'rf')
 enddef
 
+def Test_compile_error_in_called_function()
+  var lines =<< trim END
+      vim9script
+      var n: number
+      def Foo()
+        &hls = n
+      enddef
+      def Bar()
+        Foo()
+      enddef
+      silent! Foo()
+      Bar()
+  END
+  CheckScriptFailureList(lines, ['E1012:', 'E1191:'])
+enddef
+
 def Test_autoload_name_mismatch()
   var dir = 'Xdir/autoload'
   mkdir(dir, 'p')
index de03654afaab478f9514899800994f570648cadf..aee9dcff2249441c2c4df335df4070eae8ad831c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2965,
 /**/
     2964,
 /**/
index 28108bfe7d1089e6a8299d04177c9a728afc5fa2..6fcad3db4440cbb4101963100a30f38a9ab69b17 100644 (file)
@@ -1950,6 +1950,12 @@ generate_CALL(cctx_T *cctx, ufunc_T *ufunc, int pushed_argcount)
                                               PROFILING(ufunc), NULL) == FAIL)
            return FAIL;
     }
+    if (ufunc->uf_def_status == UF_COMPILE_ERROR)
+    {
+       emsg_funcname(_(e_call_to_function_that_failed_to_compile_str),
+                                                              ufunc->uf_name);
+       return FAIL;
+    }
 
     if ((isn = generate_instr(cctx,
                    ufunc->uf_def_status != UF_NOT_COMPILED ? ISN_DCALL