patch 9.1.0952: Vim9: missing type checking for any type assignment
Problem: Vim9: missing type checking for any type assignment
(Ernie Rael)
Solution: when assigning to a list item, if the type of the LHS item is
any, then use the list item type (Yegappan Lakshmanan)
fixes: #15208
closes: #16274
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/eval.c b/src/eval.c
index 6ce5918..f4f8c05 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1489,8 +1489,17 @@
return FAIL;
if (lp->ll_valtype != NULL && !lp->ll_range)
+ {
// use the type of the member
- lp->ll_valtype = lp->ll_valtype->tt_member;
+ if (lp->ll_valtype->tt_member != NULL)
+ lp->ll_valtype = lp->ll_valtype->tt_member;
+ else
+ // If the LHS member type is not known (VAR_ANY), then get it from
+ // the list item (after indexing)
+ lp->ll_valtype = typval2type(&lp->ll_li->li_tv, get_copyID(),
+ &lp->ll_type_list, TVTT_DO_MEMBER);
+
+ }
/*
* May need to find the item or absolute index for the second
@@ -1994,6 +2003,7 @@
// Clear everything in "lp".
CLEAR_POINTER(lp);
+ ga_init2(&lp->ll_type_list, sizeof(type_T *), 10);
if (skip || (flags & GLV_COMPILING))
{
@@ -2178,6 +2188,7 @@
{
vim_free(lp->ll_exp_name);
vim_free(lp->ll_newkey);
+ clear_type_list(&lp->ll_type_list);
}
/*