1
0
forked from aniani/vim

patch 9.1.1111: Vim9: variable not found in transitive import

Problem:  Vim9: variable not found in transitive import
          (lifepillar)
Solution: fix import and class extends (Hirohito Higashi)

fixes: #16379
related: #16440
closes: #16602

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Hirohito Higashi
2025-02-13 21:04:07 +01:00
committed by Christian Brabandt
parent e70587dbdb
commit bf7c88d852
6 changed files with 98 additions and 17 deletions

View File

@@ -836,6 +836,36 @@ find_imported(char_u *name, size_t len, int load)
return ret;
}
/*
* Find "name" in imported items of extended base class of the class to which
* the context :def function belongs.
*/
imported_T *
find_imported_from_extends(cctx_T *cctx, char_u *name, size_t len, int load)
{
imported_T *ret = NULL;
class_T *cl_extends;
if (cctx == NULL || cctx->ctx_ufunc == NULL
|| cctx->ctx_ufunc->uf_class == NULL)
return NULL;
cl_extends = cctx->ctx_ufunc->uf_class->class_extends;
if (cl_extends == NULL || cl_extends->class_class_function_count_child <= 0)
return NULL;
else
{
sctx_T current_sctx_save = current_sctx;
current_sctx = cl_extends->class_class_functions[0]->uf_script_ctx;
ret = find_imported(name, len, load);
current_sctx = current_sctx_save;
return ret;
}
}
/*
* Called when checking for a following operator at "arg". When the rest of
* the line is empty or only a comment, peek the next line. If there is a next
@@ -1374,7 +1404,7 @@ generate_loadvar(cctx_T *cctx, lhs_T *lhs)
case dest_script:
case dest_script_v9:
res = compile_load_scriptvar(cctx,
name + (name[1] == ':' ? 2 : 0), NULL, NULL);
name + (name[1] == ':' ? 2 : 0), NULL, NULL, NULL);
break;
case dest_env:
// Include $ in the name here