summaryrefslogtreecommitdiffstats
path: root/src/vim9type.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2023-12-08 21:41:23 +0100
committerChristian Brabandt <cb@256bit.org>2023-12-08 21:47:22 +0100
commitd33518522a84b5625e663c1b608e1c68f9f58003 (patch)
tree55e95d51f2f0484c0d5db68f4bcb951a8a89868c /src/vim9type.c
parentf48558e10a08a1a483e25ef847bbceeac6b44561 (diff)
patch 9.0.2155: Vim9: type not kept when assigning varsv9.0.2155
Problem: Vim9: type not kept when assigning vars Solution: When assigning a List or a Dict value to a variable of type 'any', keep the type closes: #13639 closes: #13646 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/vim9type.c')
-rw-r--r--src/vim9type.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/vim9type.c b/src/vim9type.c
index 22720fb6e8..c28137fcc7 100644
--- a/src/vim9type.c
+++ b/src/vim9type.c
@@ -201,6 +201,10 @@ set_tv_type_recurse(type_T *type)
void
set_tv_type(typval_T *tv, type_T *type)
{
+ if (type->tt_type == VAR_ANY)
+ // If the variable type is "any", then keep the value type.
+ // e.g. var x: any = [1, 2] or var y: any = {v: 1}
+ return;
if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
{
dict_T *d = tv->vval.v_dict;