0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 9.1.0520: Vim9: incorrect type checking for modifying lists

Problem:  Vim9: incorrect type checking for modifying lists
Solution: Correctly assign the member declared types and generate
          typechecks, add disassembly test (LemonBoy)

fixes: #15090
closes: #15094

Signed-off-by: LemonBoy <thatlemon@gmail.com>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
LemonBoy
2024-07-04 13:43:12 +02:00
committed by Christian Brabandt
parent 9d85d4dcf9
commit f4af331d08
5 changed files with 68 additions and 1 deletions

View File

@@ -3315,7 +3315,7 @@ obj_constructor_prologue(ufunc_T *ufunc, cctx_T *cctx)
// the initialization expression type.
m->ocm_type = type;
}
else if (m->ocm_type->tt_type != type->tt_type)
else
{
// The type of the member initialization expression is
// determined at run time. Add a runtime type check.
@@ -3330,6 +3330,15 @@ obj_constructor_prologue(ufunc_T *ufunc, cctx_T *cctx)
else
push_default_value(cctx, m->ocm_type->tt_type, FALSE, NULL);
if ((m->ocm_type->tt_type == VAR_DICT
|| m->ocm_type->tt_type == VAR_LIST)
&& m->ocm_type->tt_member != NULL
&& m->ocm_type->tt_member != &t_any
&& m->ocm_type->tt_member != &t_unknown)
// Set the type in the list or dict, so that it can be checked,
// also in legacy script.
generate_SETTYPE(cctx, m->ocm_type);
generate_STORE_THIS(cctx, i);
}