patch 8.2.1256: Vim9: type wrong after getting dict item in lambda
Problem: Vim9: type wrong after getting dict item in lambda.
Solution: Set the type to "any" after enforcing dict type. (closes #6491)
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 93a4d89..ce24dd6 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3797,9 +3797,12 @@
{
if ((*typep)->tt_type == VAR_DICT)
*typep = (*typep)->tt_member;
- else if (need_type(*typep, &t_dict_any, -2, cctx, FALSE)
- == FAIL)
- return FAIL;
+ else
+ {
+ if (need_type(*typep, &t_dict_any, -2, cctx, FALSE) == FAIL)
+ return FAIL;
+ *typep = &t_any;
+ }
if (may_generate_2STRING(-1, cctx) == FAIL)
return FAIL;
if (generate_instr_drop(cctx, ISN_MEMBER, 1) == FAIL)