Mercurial > vim
diff src/evalvars.c @ 25186:0a3b1c66d3f2 v8.2.3129
patch 8.2.3129: Vim9: imported uninitialized list does not get type checked
Commit: https://github.com/vim/vim/commit/c967d57aa9a6bede0f50c6986dcddc1dc035a354
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jul 8 21:38:50 2021 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 08 Jul 2021 21:45:04 +0200 |
parents | e495f40e4b07 |
children | 346002a63bc6 |
line wrap: on
line diff
--- 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); - - // TODO: check imported variable + svar_T *sv = find_typval_in_script(tv); + if (sv != NULL) type = sv->sv_type; }