summaryrefslogtreecommitdiff
path: root/src/evalvars.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-15 14:31:20 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-15 14:31:20 +0200
commit53b29e4845857d76ca7df1ff2fd0e03c3eeb82e1 (patch)
tree6b89dae5074bf8892cde67ba75b7dda045364bf4 /src/evalvars.c
parent9a5c553f790f74e4c36295ce5d46c1aa7d13eae6 (diff)
downloadvim-git-53b29e4845857d76ca7df1ff2fd0e03c3eeb82e1.tar.gz
patch 8.2.1459: Vim9: declaring script var in script does not infer the typev8.2.1459
Problem: Vim9: declaring ascript variable at the script level does not infer the type. Solution: Get the type from the value. (closes #6716)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r--src/evalvars.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/evalvars.c b/src/evalvars.c
index 43c05fdf8..d948ddec5 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -3049,7 +3049,10 @@ set_var_const(
+ si->sn_var_vals.ga_len;
sv->sv_name = di->di_key;
sv->sv_tv = &di->di_tv;
- sv->sv_type = type == NULL ? &t_any : type;
+ if (type == NULL)
+ sv->sv_type = typval2type(tv, &si->sn_type_list);
+ else
+ sv->sv_type = type;
sv->sv_const = (flags & LET_IS_CONST);
sv->sv_export = is_export;
++si->sn_var_vals.ga_len;