From 320478cb5a54b80618b66d3553e8f16504388062 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 28 Apr 2019 11:10:03 +1000 Subject: [PATCH] oceani: disallow assignment if no 'dup' operation. 'dup' is needed for assignment, so if it isn't present it must be forbidden. Signed-off-by: NeilBrown --- csrc/oceani.mdc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index 2be4d5d..7e74b84 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -2517,7 +2517,9 @@ it is declared, and error will be raised as the name is created as case Assign: case Declare: - /* Both must match and not be labels, result is Tnone */ + /* Both must match and not be labels, + * Type must support 'dup', + * result is Tnone */ t = propagate_types(b->left, c, ok, NULL, Rnolabel); if (!b->right) return Tnone; @@ -2532,6 +2534,10 @@ it is declared, and error will be raised as the name is created as if (t) propagate_types(b->left, c, ok, t, 0); } + if (t && t->dup == NULL) { + type_err(c, "error: cannot assign value of type %1", b, t, 0, NULL); + *ok = 0; + } return Tnone; break; -- 2.43.0