0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.4174: Vim9: can use an autoload name in normal script

Problem:    Vim9: can use an autoload name in normal script.
Solution:   Disallow using an autoload name.
This commit is contained in:
Bram Moolenaar
2022-01-21 20:37:05 +00:00
parent e70dd11ef4
commit 19e69a6330
4 changed files with 22 additions and 1 deletions

View File

@@ -3209,7 +3209,8 @@ EXTERN char e_cannot_import_dot_vim_without_using_as[]
INIT(= N_("E1261: Cannot import .vim without using \"as\"")); INIT(= N_("E1261: Cannot import .vim without using \"as\""));
EXTERN char e_cannot_import_same_script_twice_str[] EXTERN char e_cannot_import_same_script_twice_str[]
INIT(= N_("E1262: Cannot import the same script twice: %s")); INIT(= N_("E1262: Cannot import the same script twice: %s"));
// E1263 unused EXTERN char e_using_autoload_name_in_non_autoload_script_str[]
INIT(= N_("E1263: Using autoload name in a non-autoload script: %s"));
EXTERN char e_autoload_import_cannot_use_absolute_or_relative_path[] EXTERN char e_autoload_import_cannot_use_absolute_or_relative_path[]
INIT(= N_("E1264: Autoload import cannot use absolute or relative path: %s")); INIT(= N_("E1264: Autoload import cannot use absolute or relative path: %s"));
EXTERN char e_cannot_use_partial_here[] EXTERN char e_cannot_use_partial_here[]

View File

@@ -1622,6 +1622,18 @@ def Test_autoload_missing_function_name()
delete('Xdir', 'rf') delete('Xdir', 'rf')
enddef enddef
def Test_autoload_name_wring()
var lines =<< trim END
vim9script
def Xscriptname#Func()
enddef
END
writefile(lines, 'Xscriptname.vim')
CheckScriptFailure(lines, 'E1263:')
delete('Xscriptname')
enddef
def Test_import_autoload_postponed() def Test_import_autoload_postponed()
mkdir('Xdir/autoload', 'p') mkdir('Xdir/autoload', 'p')
var save_rtp = &rtp var save_rtp = &rtp

View File

@@ -4495,6 +4495,12 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free)
} }
} }
} }
else if (vim9script && vim_strchr(name, AUTOLOAD_CHAR) != NULL)
{
semsg(_(e_using_autoload_name_in_non_autoload_script_str),
name);
goto erret;
}
} }
if (var_conflict) if (var_conflict)
{ {

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 */
/**/
4174,
/**/ /**/
4173, 4173,
/**/ /**/