summaryrefslogtreecommitdiffstats
path: root/src/vim9instr.c
diff options
context:
space:
mode:
authorErnie Rael <errael@raelity.com>2024-04-24 20:07:50 +0200
committerChristian Brabandt <cb@256bit.org>2024-04-24 20:07:50 +0200
commit3f821d6de2586d921fb23e2facb4764ef9eb3294 (patch)
treec576910f877e4e43093a534172c1a4e7bdf329c4 /src/vim9instr.c
parent04e8943556fbe2e53ce611f753141442bc8c655a (diff)
patch 9.1.0369: Vim9: problem when importing autoloaded scriptsv9.1.0369
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>
Diffstat (limited to 'src/vim9instr.c')
-rw-r--r--src/vim9instr.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/vim9instr.c b/src/vim9instr.c
index 4df63fd09a..ad8beb1a30 100644
--- a/src/vim9instr.c
+++ b/src/vim9instr.c
@@ -2394,6 +2394,7 @@ generate_store_var(
case dest_vimvar:
return generate_STORE(cctx, ISN_STOREV, vimvaridx, NULL);
case dest_script:
+ case dest_script_v9:
{
int scriptvar_idx = lhs->lhs_scriptvar_idx;
int scriptvar_sid = lhs->lhs_scriptvar_sid;
@@ -2401,10 +2402,14 @@ generate_store_var(
{
isntype_T isn_type = ISN_STORES;
+ // If "sn_import_autoload", generate ISN_STOREEXPORT (not
+ // ISN_STORES) if destination is in a vim9script or if
+ // there is no "sn_autoload_prefix".
if (SCRIPT_ID_VALID(scriptvar_sid)
&& SCRIPT_ITEM(scriptvar_sid)->sn_import_autoload
- && SCRIPT_ITEM(scriptvar_sid)->sn_autoload_prefix
- == NULL)
+ && ((SCRIPT_ITEM(scriptvar_sid)
+ ->sn_autoload_prefix == NULL)
+ || lhs->lhs_dest == dest_script_v9))
{
// "import autoload './dir/script.vim'" - load script
// first