0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.4312: no error for using :vim9script in a :def function

Problem:    No error for using :vim9script in a :def function.
Solution:   Give an error when compiling.
This commit is contained in:
Bram Moolenaar
2022-02-06 17:30:41 +00:00
parent 160afdb185
commit 107f7325f6
3 changed files with 7 additions and 0 deletions

View File

@@ -1227,6 +1227,7 @@ def Test_vim9script_fails()
v9.CheckScriptFailure(['vim9script', 'const str = "asdf"', 'str = "xxx"'], 'E46:') v9.CheckScriptFailure(['vim9script', 'const str = "asdf"', 'str = "xxx"'], 'E46:')
assert_fails('vim9script', 'E1038:') assert_fails('vim9script', 'E1038:')
v9.CheckDefFailure(['vim9script'], 'E1038:')
enddef enddef
def Test_script_var_shadows_function() def Test_script_var_shadows_function()

View File

@@ -746,6 +746,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 */
/**/
4312,
/**/ /**/
4311, 4311,
/**/ /**/

View File

@@ -3138,6 +3138,10 @@ compile_def_function(
line = compile_script(line, &cctx); line = compile_script(line, &cctx);
break; break;
case CMD_vim9script:
emsg(_(e_vim9script_can_only_be_used_in_script));
goto erret;
case CMD_global: case CMD_global:
if (check_global_and_subst(ea.cmd, p) == FAIL) if (check_global_and_subst(ea.cmd, p) == FAIL)
goto erret; goto erret;