patch 9.1.1014: Vim9: variable not found in transitive import
Problem: Vim9: variable not found in transitive import
Solution: Allow nested import (Hirohito Higashi)
fixe: #16379
closes: #16440
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/vim9compile.c b/src/vim9compile.c
index a2dd77a..fa02871 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -778,6 +778,7 @@
static imported_T *
find_imported_in_script(char_u *name, size_t len, int sid)
{
+ static int nesting = 0;
scriptitem_T *si;
int idx;
@@ -792,6 +793,19 @@
: STRLEN(import->imp_name) == len
&& STRNCMP(name, import->imp_name, len) == 0)
return import;
+ else
+ {
+ if (nesting >= p_mfd)
+ {
+ emsg(_(e_import_nesting_too_deep));
+ return NULL;
+ }
+ ++nesting;
+ import = find_imported_in_script(name, len, import->imp_sid);
+ --nesting;
+ if (import != NULL)
+ return import;
+ }
}
return NULL;
}