diff src/vim9compile.c @ 33951:45a50fd59a73 v9.0.2170

patch 9.0.2170: Vim9: no support for const/final class/objects vars Commit: https://github.com/vim/vim/commit/e5437c542709b77ade084f96e60d84d4e847e6d3 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sat Dec 16 14:11:19 2023 +0100 patch 9.0.2170: Vim9: no support for const/final class/objects vars Problem: Vim9: no support for const/final class/objects vars Solution: Support final and const object and class variables closes: #13655 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 16 Dec 2023 14:15:05 +0100
parents a259471e74fe
children 7c30841c60a0
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -1770,6 +1770,12 @@ compile_lhs(
 								lhs->lhs_name);
 		    return FAIL;
 		}
+
+		ocmember_T	*m =
+			&defcl->class_class_members[lhs->lhs_classmember_idx];
+		if (oc_var_check_ro(defcl, m))
+		    return FAIL;
+
 		lhs->lhs_dest = dest_class_member;
 		lhs->lhs_class = cctx->ctx_ufunc->uf_class;
 		lhs->lhs_type =
@@ -2040,6 +2046,10 @@ compile_lhs(
 		return FAIL;
 	    }
 
+	    if (!IS_CONSTRUCTOR_METHOD(cctx->ctx_ufunc)
+						&& oc_var_check_ro(cl, m))
+		return FAIL;
+
 	    lhs->lhs_member_type = m->ocm_type;
 	}
 	else
@@ -3356,7 +3366,7 @@ compile_def_function(
 
 		    type_T	*type = get_type_on_stack(&cctx, 0);
 		    if (m->ocm_type->tt_type == VAR_ANY
-			    && !m->ocm_has_type
+			    && !(m->ocm_flags & OCMFLAG_HAS_TYPE)
 			    && type->tt_type != VAR_SPECIAL)
 		    {
 			// If the member variable type is not yet set, then use