1
0
forked from aniani/vim

patch 9.1.0369: Vim9: problem when importing autoloaded scripts

Problem:  Vim9: problem when importing autoloaded scripts
Solution: In `:def` handle storing to vim9 autoload export
          (Ernie Rael)

Problem occurs when `import autoload ./.../autoload/...`. The autoload
in the specified path causes the use of an autoload_prefix which combines
with the `import autoload` to create trouble.

In `generate_store_var()` `case dest_script` use ISN_STOREEXPORT,
when needed, instead of ISN_STORES. When executing ISN_STOREEXPORT,
check for autoload_prefix.

fixes: #14606
closes: #14615

Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
Ernie Rael
2024-04-24 20:07:50 +02:00
committed by Christian Brabandt
parent 04e8943556
commit 3f821d6de2
9 changed files with 137 additions and 8 deletions

View File

@@ -166,6 +166,37 @@ def Test_wrong_function_name()
delfunc g:Define
enddef
" Check that in a legacy script a :def accesses the correct script variables.
" Github issue: #14615.
def Test_access_var_from_legacy_def()
# Access a script variable by name WITH "s:" prefix.
var lines =<< trim END
let s:foo = 'init'
let s:xxfoo = 'init'
def! AccessVarFromLegacyDef()
s:xxfoo = 'CHANGED'
enddef
call AccessVarFromLegacyDef()
call assert_equal('init', s:foo)
call assert_equal('CHANGED', s:xxfoo)
END
v9.CheckScriptSuccess(lines)
# Access a script variable by name WITHOUT "s:" prefix;
# previously this accessed "foo" and not "xxfoo"
lines =<< trim END
let s:foo = 'init'
let s:xxfoo = 'init'
def! AccessVarFromLegacyDef()
xxfoo = 'CHANGED'
enddef
call AccessVarFromLegacyDef()
call assert_equal('init', s:foo)
call assert_equal('CHANGED', s:xxfoo)
END
v9.CheckScriptSuccess(lines)
enddef
def Test_listing_function_error()
var lines =<< trim END
var filler = 123