mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.4330: Vim9: no error if script imports itself
Problem: Vim9: no error if script imports itself. Solution: Give an error when a script imports itself.
This commit is contained in:
@@ -2802,7 +2802,8 @@ EXTERN char e_function_reference_invalid[]
|
|||||||
INIT(= N_("E1086: Function reference invalid"));
|
INIT(= N_("E1086: Function reference invalid"));
|
||||||
EXTERN char e_cannot_use_index_when_declaring_variable[]
|
EXTERN char e_cannot_use_index_when_declaring_variable[]
|
||||||
INIT(= N_("E1087: Cannot use an index when declaring a variable"));
|
INIT(= N_("E1087: Cannot use an index when declaring a variable"));
|
||||||
// E1088 unused
|
EXTERN char e_script_cannot_import_itself[]
|
||||||
|
INIT(= N_("E1088: Script cannot import itself"));
|
||||||
EXTERN char e_unknown_variable_str[]
|
EXTERN char e_unknown_variable_str[]
|
||||||
INIT(= N_("E1089: Unknown variable: %s"));
|
INIT(= N_("E1089: Unknown variable: %s"));
|
||||||
EXTERN char e_cannot_assign_to_argument[]
|
EXTERN char e_cannot_assign_to_argument[]
|
||||||
|
@@ -500,7 +500,16 @@ def Test_import_fails()
|
|||||||
v9.CheckScriptFailure(lines, 'E1262:')
|
v9.CheckScriptFailure(lines, 'E1262:')
|
||||||
|
|
||||||
delete('Xthat.vim')
|
delete('Xthat.vim')
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
export var item = 'hello'
|
||||||
|
import './Xyourself.vim'
|
||||||
|
END
|
||||||
|
writefile(lines, 'Xyourself.vim')
|
||||||
|
assert_fails('source Xyourself.vim', 'E1088:')
|
||||||
|
delete('Xyourself.vim')
|
||||||
|
|
||||||
mkdir('Ximport')
|
mkdir('Ximport')
|
||||||
|
|
||||||
writefile(['vim9script'], 'Ximport/.vim')
|
writefile(['vim9script'], 'Ximport/.vim')
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
4330,
|
||||||
/**/
|
/**/
|
||||||
4329,
|
4329,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -516,6 +516,12 @@ handle_import(
|
|||||||
goto erret;
|
goto erret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sid == current_sctx.sc_sid)
|
||||||
|
{
|
||||||
|
emsg(_(e_script_cannot_import_itself));
|
||||||
|
goto erret;
|
||||||
|
}
|
||||||
|
|
||||||
import_gap = gap != NULL ? gap : &SCRIPT_ITEM(import_sid)->sn_imports;
|
import_gap = gap != NULL ? gap : &SCRIPT_ITEM(import_sid)->sn_imports;
|
||||||
for (i = 0; i < import_gap->ga_len; ++i)
|
for (i = 0; i < import_gap->ga_len; ++i)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user