patch 8.2.3129: Vim9: imported uninitialized list does not get type checked
Problem: Vim9: imported uninitialized list does not get type checked.
Solution: Get type from imported variable.
diff --git a/src/evalvars.c b/src/evalvars.c
index a171c82..66018cf 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -2564,9 +2564,9 @@
int ret = OK;
typval_T *tv = NULL;
int found = FALSE;
- dictitem_T *v;
hashtab_T *ht = NULL;
int cc;
+ type_T *type = NULL;
// truncate the name, so that we can use strcmp()
cc = name[len];
@@ -2576,13 +2576,16 @@
if ((tv = lookup_debug_var(name)) == NULL)
{
// Check for user-defined variables.
- v = find_var(name, &ht, flags & EVAL_VAR_NOAUTOLOAD);
+ dictitem_T *v = find_var(name, &ht, flags & EVAL_VAR_NOAUTOLOAD);
+
if (v != NULL)
{
tv = &v->di_tv;
if (dip != NULL)
*dip = v;
}
+ else
+ ht = NULL;
}
if (tv == NULL && (in_vim9script() || STRNCMP(name, "s:", 2) == 0))
@@ -2628,6 +2631,7 @@
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data)
+ import->imp_var_vals_idx;
tv = sv->sv_tv;
+ type = sv->sv_type;
}
}
else if (in_vim9script())
@@ -2656,13 +2660,10 @@
}
else if (rettv != NULL)
{
- type_T *type = NULL;
-
if (ht != NULL && ht == get_script_local_ht())
{
- svar_T *sv = find_typval_in_script(tv, FALSE);
+ svar_T *sv = find_typval_in_script(tv);
- // TODO: check imported variable
if (sv != NULL)
type = sv->sv_type;
}