Mercurial > vim
diff src/vim9compile.c @ 33534:c8bd88bdb630 v9.0.2016
patch 9.0.2016: Vim9: assignment operators don't work for class vars
Commit: https://github.com/vim/vim/commit/1ea428883f16838aca5763aee156fde3929d9ab6
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Wed Oct 11 21:43:52 2023 +0200
patch 9.0.2016: Vim9: assignment operators don't work for class vars
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>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 11 Oct 2023 22:00:03 +0200 |
parents | f61713271934 |
children | 86dbcbb94fdb |
line wrap: on
line diff
--- 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, 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, 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);