patch 9.1.1146: Vim9: wrong context being used when evaluating class member
Problem: Vim9: wrong context being used when evaluating class member
(lifepillar, Ernie Rael)
Solution: Use the correct script context when evaluating a class member
init expression(Yegappan Lakshmanan)
fixes: #14011
fixes: #14402
closes: #15112
closes: #16660
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
5090a1fecb
commit
16f2d3a465
@ -204,7 +204,13 @@ add_member(
|
||||
m->ocm_flags |= OCMFLAG_HAS_TYPE;
|
||||
m->ocm_type = type;
|
||||
if (init_expr != NULL)
|
||||
{
|
||||
m->ocm_init = init_expr;
|
||||
// Save the script context, we need it when evaluating or compiling the
|
||||
// initializer expression.
|
||||
m->ocm_init_sctx = current_sctx;
|
||||
m->ocm_init_sctx.sc_lnum += SOURCING_LNUM;
|
||||
}
|
||||
++gap->ga_len;
|
||||
return OK;
|
||||
}
|
||||
@ -1355,7 +1361,11 @@ add_class_members(class_T *cl, exarg_T *eap, garray_T *type_list_gap)
|
||||
typval_T *tv = &cl->class_members_tv[i];
|
||||
if (m->ocm_init != NULL)
|
||||
{
|
||||
sctx_T save_current_sctx = current_sctx;
|
||||
|
||||
current_sctx = m->ocm_init_sctx;
|
||||
typval_T *etv = eval_expr(m->ocm_init, eap);
|
||||
current_sctx = save_current_sctx;
|
||||
if (etv == NULL)
|
||||
return FAIL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user