assert_fails('trip.four = 4', 'E1334')
END
v9.CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
+
+ class MyCar
+ this.make: string
+
+ def new(make_arg: string)
+ this.make = make_arg
+ enddef
+
+ def GetMake(): string
+ return $"make = {this.make}"
+ enddef
+ endclass
+
+ var c = MyCar.new("abc")
+ assert_equal('make = abc', c.GetMake())
+
+ c = MyCar.new("def")
+ assert_equal('make = def', c.GetMake())
+
+ var c2 = MyCar.new("123")
+ assert_equal('make = 123', c2.GetMake())
+ END
+ v9.CheckScriptSuccess(lines)
enddef
def Test_class_member_access()
tv->vval.v_number = iptr->isn_arg.storenr.stnr_val;
break;
- // store value in list or dict variable
+ // Store a value in a list, dict, blob or object variable.
case ISN_STOREINDEX:
{
int res = execute_storeindex(iptr, ectx);
object_T *obj = tv->vval.v_object;
// the members are located right after the object struct
typval_T *mtv = ((typval_T *)(obj + 1)) + idx;
- *tv = *mtv;
+ copy_tv(mtv, tv);
// Unreference the object after getting the member, it may
// be freed.