diff src/vim9execute.c @ 27086:1e2a6c6c7e42 v8.2.4072

patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded Commit: https://github.com/vim/vim/commit/d041f4208b0a2149e9d41f6443aa1c14c076a411 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 12 19:54:00 2022 +0000 patch 8.2.4072: Vim9: compiling function fails when autoload is not loaded Problem: Vim9: compiling function fails when autoload script is not loaded yet. Solution: Depend on runtime loading.
author Bram Moolenaar <Bram@vim.org>
date Wed, 12 Jan 2022 21:00:05 +0100
parents c9474ae175f4
children 98a01021e465
line wrap: on
line diff
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -2227,6 +2227,16 @@ exec_instructions(ectx_T *ectx)
 		    }
 		    di = find_var_in_ht(ht, 0, iptr->isn_arg.string, TRUE);
 
+		    if (di == NULL && ht == get_globvar_ht())
+		    {
+			// may need to load autoload script
+			if (script_autoload(iptr->isn_arg.string, FALSE))
+			    di = find_var_in_ht(ht, 0,
+						   iptr->isn_arg.string, TRUE);
+			if (did_emsg)
+			    goto on_error;
+		    }
+
 		    if (di == NULL)
 		    {
 			SOURCING_LNUM = iptr->isn_lnum;