0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.3411: Vim9: crash when using base name of import

Problem:    Vim9: crash when using base name of import. (Naohiro Ono)
Solution:   Check the import flags. (closes #8843)
This commit is contained in:
Bram Moolenaar 2021-09-07 22:12:19 +02:00
parent 89a54b413a
commit 6853c38b78
4 changed files with 25 additions and 0 deletions

View File

@ -654,3 +654,5 @@ EXTERN char e_legacy_must_be_followed_by_command[]
INIT(= N_("E1234: legacy must be followed by a command"));
EXTERN char e_function_reference_is_not_set[]
INIT(= N_("E1235: Function reference is not set"));
EXTERN char e_cannot_use_str_itself_it_is_imported_with_star[]
INIT(= N_("E1236: Cannot use %s itself, it is imported with '*'"));

View File

@ -3260,6 +3260,12 @@ set_var_const(
semsg(_(e_redefining_imported_item_str), name);
goto failed;
}
if (import->imp_flags & IMP_FLAGS_STAR)
{
semsg(_(e_cannot_use_str_itself_it_is_imported_with_star),
name);
goto failed;
}
sv = ((svar_T *)si->sn_var_vals.ga_data) + import->imp_var_vals_idx;
where.wt_variable = TRUE;

View File

@ -1477,6 +1477,21 @@ def Test_vim9_import_export()
delete('Xvim9_script')
enddef
def Test_import_star_fails()
writefile([], 'Xfoo.vim')
var lines =<< trim END
import * as foo from '/tmp/foo.vim'
foo = 'bar'
END
CheckDefAndScriptFailure2(lines, 'E1094:', 'E1236: Cannot use foo itself')
lines =<< trim END
vim9script
import * as foo from '/tmp/foo.vim'
var that = foo
END
CheckScriptFailure(lines, 'E1029: Expected ''.''')
enddef
def Test_import_as()
var export_lines =<< trim END
vim9script

View File

@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3411,
/**/
3410,
/**/