diff src/vim9compile.c @ 35037:5df4ad0a5200 v9.1.0369

patch 9.1.0369: Vim9: problem when importing autoloaded scripts Commit: https://github.com/vim/vim/commit/3f821d6de2586d921fb23e2facb4764ef9eb3294 Author: Ernie Rael <errael@raelity.com> Date: Wed Apr 24 20:07:50 2024 +0200 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>
author Christian Brabandt <cb@256bit.org>
date Wed, 24 Apr 2024 20:15:03 +0200
parents eeab9c4c801b
children 2e492a1539e0
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -1367,6 +1367,7 @@ generate_loadvar(cctx_T *cctx, lhs_T *lh
 	    generate_LOAD(cctx, ISN_LOADT, 0, name + 2, type);
 	    break;
 	case dest_script:
+	case dest_script_v9:
 	    res = compile_load_scriptvar(cctx,
 				  name + (name[1] == ':' ? 2 : 0), NULL, NULL);
 	    break;
@@ -1838,7 +1839,8 @@ compile_lhs(
 			return FAIL;
 		    }
 
-		    lhs->lhs_dest = dest_script;
+		    lhs->lhs_dest = current_script_is_vim9()
+			      ? dest_script_v9 : dest_script;
 
 		    // existing script-local variables should have a type
 		    lhs->lhs_scriptvar_sid = current_sctx.sc_sid;
@@ -3026,8 +3028,9 @@ compile_assignment(
 	else
 	{
 	    if (is_decl && cmdidx == CMD_const && (lhs.lhs_dest == dest_script
-						|| lhs.lhs_dest == dest_global
-						|| lhs.lhs_dest == dest_local))
+					    || lhs.lhs_dest == dest_script_v9
+					    || lhs.lhs_dest == dest_global
+					    || lhs.lhs_dest == dest_local))
 		// ":const var": lock the value, but not referenced variables
 		generate_LOCKCONST(cctx);