]> ocean-lang.org Git - ocean/commitdiff
oceani: disallow assignment if no 'dup' operation.
authorNeilBrown <neil@brown.name>
Sun, 28 Apr 2019 01:10:03 +0000 (11:10 +1000)
committerNeilBrown <neil@brown.name>
Wed, 1 May 2019 08:09:44 +0000 (18:09 +1000)
'dup' is needed for assignment, so if it isn't present
it must be forbidden.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/oceani.mdc

index 2be4d5db5a37a5512e85699f1be046a79098d280..7e74b8480c0073cd28c295f7abd50b36677d53c4 100644 (file)
@@ -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;