mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Problem: Vim9: Cannot modify class member vars from def function Solution: Add support for modifying class member variables from a def function closes: #12995 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
committed by
Christian Brabandt
parent
b147d31489
commit
3775f777a6
@@ -2144,7 +2144,7 @@ execute_storeindex(isn_T *iptr, ectx_T *ectx)
|
||||
// Stack contains:
|
||||
// -3 value to be stored
|
||||
// -2 index
|
||||
// -1 dict, list, blob or object
|
||||
// -1 dict, list, blob, object or class
|
||||
tv = STACK_TV_BOT(-3);
|
||||
SOURCING_LNUM = iptr->isn_lnum;
|
||||
|
||||
@@ -2306,14 +2306,25 @@ execute_storeindex(isn_T *iptr, ectx_T *ectx)
|
||||
}
|
||||
else if (dest_type == VAR_CLASS || dest_type == VAR_OBJECT)
|
||||
{
|
||||
object_T *obj = tv_dest->vval.v_object;
|
||||
typval_T *otv = (typval_T *)(obj + 1);
|
||||
typval_T *otv;
|
||||
|
||||
class_T *itf = iptr->isn_arg.storeindex.si_class;
|
||||
if (itf != NULL)
|
||||
// convert interface member index to class member index
|
||||
lidx = object_index_from_itf_index(itf, FALSE,
|
||||
lidx, obj->obj_class);
|
||||
if (dest_type == VAR_OBJECT)
|
||||
{
|
||||
object_T *obj = tv_dest->vval.v_object;
|
||||
|
||||
otv = (typval_T *)(obj + 1);
|
||||
class_T *itf = iptr->isn_arg.storeindex.si_class;
|
||||
if (itf != NULL)
|
||||
// convert interface member index to class member index
|
||||
lidx = object_index_from_itf_index(itf, FALSE,
|
||||
lidx, obj->obj_class);
|
||||
}
|
||||
else
|
||||
{
|
||||
// VAR_CLASS
|
||||
class_T *class = tv_dest->vval.v_class;
|
||||
otv = class->class_members_tv;
|
||||
}
|
||||
|
||||
clear_tv(&otv[lidx]);
|
||||
otv[lidx] = *tv;
|
||||
|
Reference in New Issue
Block a user