From c967d57aa9a6bede0f50c6986dcddc1dc035a354 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 8 Jul 2021 21:38:50 +0200 Subject: 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. --- src/evalvars.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/evalvars.c') diff --git a/src/evalvars.c b/src/evalvars.c index a171c822f..66018cff0 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -2564,9 +2564,9 @@ eval_variable( 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 @@ eval_variable( 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 @@ eval_variable( 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 @@ eval_variable( } 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; } -- cgit v1.2.1