Mercurial > vim
changeset 25751:fc8046209eaa v8.2.3411
patch 8.2.3411: Vim9: crash when using base name of import
Commit: https://github.com/vim/vim/commit/6853c38b78fe5333f95470e1ff3ca6741247e600
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Sep 7 22:12:19 2021 +0200
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 https://github.com/vim/vim/issues/8843)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 07 Sep 2021 22:15:03 +0200 |
parents | 06e0400d9d69 |
children | a4af090364f6 |
files | src/errors.h src/evalvars.c src/testdir/test_vim9_script.vim src/version.c |
diffstat | 4 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/errors.h +++ b/src/errors.h @@ -654,3 +654,5 @@ EXTERN char e_legacy_must_be_followed_by 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 '*'"));
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -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;
--- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -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