patch 9.0.1201: assignment with operator doesn't work in object method
Problem: Assignment with operator doesn't work in object method.
Solution: Handle loading the object member. (closes #11820) Add a few more
tests.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index cc7a3bd..2b65ff9 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2044,6 +2044,21 @@
int
compile_load_lhs_with_index(lhs_T *lhs, char_u *var_start, cctx_T *cctx)
{
+ if (lhs->lhs_type->tt_type == VAR_OBJECT)
+ {
+ // "this.value": load "this" object and get the value at index
+ // for an object or class member get the type of the member
+ class_T *cl = (class_T *)lhs->lhs_type->tt_member;
+ type_T *type = class_member_type(cl, var_start + 5,
+ lhs->lhs_end, &lhs->lhs_member_idx);
+ if (lhs->lhs_member_idx < 0)
+ return FAIL;
+
+ if (generate_LOAD(cctx, ISN_LOAD, 0, NULL, lhs->lhs_type) == FAIL)
+ return FAIL;
+ return generate_GET_OBJ_MEMBER(cctx, lhs->lhs_member_idx, type);
+ }
+
compile_load_lhs(lhs, var_start, NULL, cctx);
if (lhs->lhs_has_index)