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>
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 5af3af6..3a3960a 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -3842,11 +3842,19 @@
case ISN_STOREEXPORT:
{
int sid = iptr->isn_arg.loadstore.ls_sid;
- hashtab_T *ht = &SCRIPT_VARS(sid);
char_u *name = iptr->isn_arg.loadstore.ls_name;
- dictitem_T *di = find_var_in_ht(ht, 0,
- iptr->isn_type == ISN_STORES
+ dictitem_T *di = NULL;
+ // First check for a variable from an exported autoload
+ // with an autoload_prefix; it would be in globals.
+ if (iptr->isn_type == ISN_STOREEXPORT)
+ di = find_var_autoload_prefix(name, sid, NULL, NULL);
+ // Then look for a variable in the script's variables.
+ if (di == NULL)
+ {
+ hashtab_T *ht = &SCRIPT_VARS(sid);
+ di = find_var_in_ht(ht, 0, STRNCMP("s:", name, 2) == 0
? name + 2 : name, TRUE);
+ }
--ectx->ec_stack.ga_len;
SOURCING_LNUM = iptr->isn_lnum;