summaryrefslogtreecommitdiffstats
path: root/src/vim9compile.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2023-10-11 21:43:52 +0200
committerChristian Brabandt <cb@256bit.org>2023-10-11 21:43:52 +0200
commit1ea428883f16838aca5763aee156fde3929d9ab6 (patch)
treef5bbcbcfe81da0df16fd416ed62fb71c383c4ba8 /src/vim9compile.c
parent4c8da025ef8140168b7a09d9fe922ce4bb40f19d (diff)
patch 9.0.2016: Vim9: assignment operators don't work for class varsv9.0.2016
Problem: Vim9: assignment operators don't work for class vars Solution: implement it closes: #13306 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r--src/vim9compile.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 7e1914b694..544ad17e10 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -1770,7 +1770,7 @@ compile_lhs(
lhs->lhs_dest = dest_class_member;
lhs->lhs_class = cctx->ctx_ufunc->uf_class;
lhs->lhs_type =
- class_member_type_by_idx(cctx->ctx_ufunc->uf_class,
+ oc_member_type_by_idx(cctx->ctx_ufunc->uf_class,
FALSE, lhs->lhs_classmember_idx);
}
else
@@ -2254,7 +2254,7 @@ compile_load_lhs_with_index(lhs_T *lhs, char_u *var_start, cctx_T *cctx)
return FAIL;
class_T *cl = lhs->lhs_type->tt_class;
- type_T *type = class_member_type(cl, TRUE, dot + 1,
+ type_T *type = oc_member_type(cl, TRUE, dot + 1,
lhs->lhs_end, &lhs->lhs_member_idx);
if (lhs->lhs_member_idx < 0)
return FAIL;
@@ -2275,6 +2275,22 @@ compile_load_lhs_with_index(lhs_T *lhs, char_u *var_start, cctx_T *cctx)
return generate_GET_ITF_MEMBER(cctx, cl, lhs->lhs_member_idx, type);
return generate_GET_OBJ_MEMBER(cctx, lhs->lhs_member_idx, type);
}
+ else if (lhs->lhs_type->tt_type == VAR_CLASS)
+ {
+ // "<classname>.value": load class variable "classname.value"
+ char_u *dot = vim_strchr(var_start, '.');
+ if (dot == NULL)
+ return FAIL;
+
+ class_T *cl = lhs->lhs_type->tt_class;
+ ocmember_T *m = class_member_lookup(cl, dot + 1,
+ lhs->lhs_end - dot - 1,
+ &lhs->lhs_member_idx);
+ if (m == NULL)
+ return FAIL;
+
+ return generate_CLASSMEMBER(cctx, TRUE, cl, lhs->lhs_member_idx);
+ }
compile_load_lhs(lhs, var_start, NULL, cctx);