diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-06-08 22:01:53 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-06-08 22:01:53 +0200 |
commit | b55d618f193d9f413612d8d4e62758056e842e46 (patch) | |
tree | c853bc4eef70faf63cd7ba3c12f7a3ab6ee1dc2d | |
parent | a733042b124357225e4081e10ef28591236c6077 (diff) | |
download | vim-git-b55d618f193d9f413612d8d4e62758056e842e46.tar.gz |
patch 8.2.2965: Vim9: crash when calling function that failed to compilev8.2.2965
Problem: Vim9: crash when calling function that failed to compile.
Solution: Fail when trying to call the function. (closes #8344)
-rw-r--r-- | src/errors.h | 2 | ||||
-rw-r--r-- | src/testdir/test_vim9_func.vim | 16 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 6 |
4 files changed, 26 insertions, 0 deletions
diff --git a/src/errors.h b/src/errors.h index 94a752ae6..fac3e26d8 100644 --- a/src/errors.h +++ b/src/errors.h @@ -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")); diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 7e21b3788..cd2a15d2d 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -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') diff --git a/src/version.c b/src/version.c index de03654af..aee9dcff2 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 */ /**/ + 2965, +/**/ 2964, /**/ 2963, diff --git a/src/vim9compile.c b/src/vim9compile.c index 28108bfe7..6fcad3db4 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -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 |