patch 8.2.2162: Vim9: Cannot load or store autoload variables
Problem: Vim9: Cannot load or store autoload variables.
Solution: Add ISN_LOADAUTO and ISN_STOREAUTO. (closes #7485)
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 207ceb4..c584918 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2535,7 +2535,17 @@
case 's': res = compile_load_scriptvar(cctx, name,
NULL, NULL, error);
break;
- case 'g': isn_type = ISN_LOADG; break;
+ case 'g': if (vim_strchr(name, AUTOLOAD_CHAR) == NULL)
+ isn_type = ISN_LOADG;
+ else
+ {
+ isn_type = ISN_LOADAUTO;
+ vim_free(name);
+ name = vim_strnsave(*arg, end - *arg);
+ if (name == NULL)
+ return FAIL;
+ }
+ break;
case 'w': isn_type = ISN_LOADW; break;
case 't': isn_type = ISN_LOADT; break;
case 'b': isn_type = ISN_LOADB; break;
@@ -2738,7 +2748,7 @@
if (compile_arguments(arg, cctx, &argcount) == FAIL)
goto theend;
- is_autoload = vim_strchr(name, '#') != NULL;
+ is_autoload = vim_strchr(name, AUTOLOAD_CHAR) != NULL;
if (ASCII_ISLOWER(*name) && name[1] != ':' && !is_autoload)
{
int idx;
@@ -4986,7 +4996,10 @@
generate_LOAD(cctx, ISN_LOADOPT, 0, name, type);
break;
case dest_global:
- generate_LOAD(cctx, ISN_LOADG, 0, name + 2, type);
+ if (vim_strchr(name, AUTOLOAD_CHAR) == NULL)
+ generate_LOAD(cctx, ISN_LOADG, 0, name + 2, type);
+ else
+ generate_LOAD(cctx, ISN_LOADAUTO, 0, name, type);
break;
case dest_buffer:
generate_LOAD(cctx, ISN_LOADB, 0, name + 2, type);
@@ -5198,7 +5211,8 @@
opt_flags);
case dest_global:
// include g: with the name, easier to execute that way
- return generate_STORE(cctx, ISN_STOREG, 0, name);
+ return generate_STORE(cctx, vim_strchr(name, AUTOLOAD_CHAR) == NULL
+ ? ISN_STOREG : ISN_STOREAUTO, 0, name);
case dest_buffer:
// include b: with the name, easier to execute that way
return generate_STORE(cctx, ISN_STOREB, 0, name);
@@ -8007,6 +8021,7 @@
{
case ISN_DEF:
case ISN_EXEC:
+ case ISN_LOADAUTO:
case ISN_LOADB:
case ISN_LOADENV:
case ISN_LOADG:
@@ -8017,6 +8032,7 @@
case ISN_PUSHFUNC:
case ISN_PUSHS:
case ISN_RANGE:
+ case ISN_STOREAUTO:
case ISN_STOREB:
case ISN_STOREENV:
case ISN_STOREG: