0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.2965: Vim9: crash when calling function that failed to compile

Problem:    Vim9: crash when calling function that failed to compile.
Solution:   Fail when trying to call the function. (closes #8344)
This commit is contained in:
Bram Moolenaar
2021-06-08 22:01:53 +02:00
parent a733042b12
commit b55d618f19
4 changed files with 26 additions and 0 deletions

View File

@@ -423,3 +423,5 @@ EXTERN char e_one_argument_too_few[]
INIT(= N_("E1190: One argument too few")); INIT(= N_("E1190: One argument too few"));
EXTERN char e_nr_arguments_too_few[] EXTERN char e_nr_arguments_too_few[]
INIT(= N_("E1190: %d 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"));

View File

@@ -74,6 +74,22 @@ def TestCompilingErrorInTry()
delete('Xdir', 'rf') delete('Xdir', 'rf')
enddef 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() def Test_autoload_name_mismatch()
var dir = 'Xdir/autoload' var dir = 'Xdir/autoload'
mkdir(dir, 'p') mkdir(dir, 'p')

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 */
/**/
2965,
/**/ /**/
2964, 2964,
/**/ /**/

View File

@@ -1950,6 +1950,12 @@ generate_CALL(cctx_T *cctx, ufunc_T *ufunc, int pushed_argcount)
PROFILING(ufunc), NULL) == FAIL) PROFILING(ufunc), NULL) == FAIL)
return 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, if ((isn = generate_instr(cctx,
ufunc->uf_def_status != UF_NOT_COMPILED ? ISN_DCALL ufunc->uf_def_status != UF_NOT_COMPILED ? ISN_DCALL