oceani: discard Rnolabel
authorNeilBrown <neil@brown.name>
Tue, 14 Dec 2021 10:24:14 +0000 (21:24 +1100)
committerNeilBrown <neil@brown.name>
Tue, 14 Dec 2021 10:24:14 +0000 (21:24 +1100)
With the new approach to labels, this flag does make any sense.
Labels are more clearly typed now.

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

index 2ac2f56d620a67ce6883cb3518a7a022298e64e9..fc26950189e93bdc61e11e590a4d29429f294c2b 100644 (file)
@@ -981,7 +981,7 @@ various places that `type_err()` are called.
        .tmp.code:33:14: error: field reference on string is not supported
        .tmp.code:34:14: error: cannot find requested field in foo
        .tmp.code:35:17: error: have string but need number
-       .tmp.code:38:29: error: expected number (labels not permitted) found Boolean
+       .tmp.code:38:29: error: expected number found Boolean
        oceani: type error in program - not running.
 
 ###### test: type_err4
index e147baa1303ed29643c8f4b43c0c5c0bebd04fb8..f1c337fd688f2c94fafdfdf6389851cffa0dd252 100644 (file)
@@ -596,16 +596,10 @@ If it remains unchanged at `0`, then no more propagation is needed.
 
 ###### ast
 
-       enum val_rules {Rnolabel = 1<<0, Rboolok = 1<<1, Rnoconstant = 1<<2};
+       enum val_rules {Rboolok = 1<<1, Rnoconstant = 1<<2};
        enum prop_err {Efail = 1<<0, Eretry = 1<<1, Enoconst = 1<<2,
                       Emaycopy = 1<<3};
 
-###### format cases
-       case 'r':
-               if (rules & Rnolabel)
-                       fputs(" (labels not permitted)", stderr);
-               break;
-
 ###### forward decls
        static struct type *propagate_types(struct exec *prog, struct parse_context *c, enum prop_err *perr,
                                            struct type *type, int rules);
@@ -1065,8 +1059,6 @@ A separate function encoding these cases will simplify some code later.
        {
                if ((rules & Rboolok) && have == Tbool)
                        return 1;       // NOTEST
-               if ((rules & Rnolabel) && have == Tlabel)
-                       return 0;       // NOTEST
                if (!require || !have)
                        return 1;
 
@@ -1319,7 +1311,7 @@ executable.
        {
                struct val *val = cast(val, prog);
                if (!type_compat(type, val->vtype, rules))
-                       type_err(c, "error: expected %1%r found %2",
+                       type_err(c, "error: expected %1 found %2",
                                   prog, type, rules, val->vtype);
                return val->vtype;
        }
@@ -1441,7 +1433,7 @@ match "case".
                struct label *l = cast(label, prog);
                l->value = label_lookup(c, l->name);
                if (!type_compat(type, Tlabel, rules))
-                       type_err(c, "error: expected %1%r found %2",
+                       type_err(c, "error: expected %1 found %2",
                                 prog, type, rules, Tlabel);
                return Tlabel;
        }
@@ -2291,7 +2283,7 @@ correctly.
                                *perr |= Eretry;
                        }
                } else if (!type_compat(type, v->type, rules)) {
-                       type_err(c, "error: expected %1%r but variable '%v' is %2", prog,
+                       type_err(c, "error: expected %1 but variable '%v' is %2", prog,
                                 type, rules, v->type);
                        type_err(c, "info: this is where '%v' was set to %1", v->where_set,
                                 v->type, rules, NULL);
@@ -3790,8 +3782,8 @@ there.
                struct type *t2;
 
                propagate_types(b->left, c, perr, Tbool, 0);
-               t = propagate_types(b2->left, c, perr, type, Rnolabel);
-               t2 = propagate_types(b2->right, c, perr, type ?: t, Rnolabel);
+               t = propagate_types(b2->left, c, perr, type, 0);
+               t2 = propagate_types(b2->right, c, perr, type ?: t, 0);
                return t ?: t2;
        }
 
@@ -4073,11 +4065,11 @@ expression operator, and the `CMPop` non-terminal will match one of them.
        case Eql:
        case NEql:
                /* Both must match but not be labels, result is Tbool */
-               t = propagate_types(b->left, c, perr, NULL, Rnolabel);
+               t = propagate_types(b->left, c, perr, NULL, 0);
                if (t)
                        propagate_types(b->right, c, perr, t, 0);
                else {
-                       t = propagate_types(b->right, c, perr, NULL, Rnolabel); // UNTESTED
+                       t = propagate_types(b->right, c, perr, NULL, 0);        // UNTESTED
                        if (t)  // UNTESTED
                                t = propagate_types(b->left, c, perr, t, 0);    // UNTESTED
                }
@@ -4594,7 +4586,7 @@ the common header for all reductions to use.
                                if (!type)
                                        type = t;
                                else if (t != type)
-                                       type_err(c, "error: expected %1%r, found %2",
+                                       type_err(c, "error: expected %1, found %2",
                                                 e->left, type, rules, t);
                        }
                }
@@ -4671,7 +4663,7 @@ printed.
                else
                        b = cast(binode, b->right);
                while (b) {
-                       propagate_types(b->left, c, perr, NULL, Rnolabel);
+                       propagate_types(b->left, c, perr, NULL, 0);
                        b = cast(binode, b->right);
                }
                break;
@@ -4789,7 +4781,7 @@ be declared at any time.
                 * result is Tnone
                 */
                t = propagate_types(b->left, c, perr, NULL,
-                                   Rnolabel | (b->op == Assign ? Rnoconstant : 0));
+                                   (b->op == Assign ? Rnoconstant : 0));
                if (!b->right)
                        return Tnone;
 
@@ -4799,7 +4791,7 @@ be declared at any time.
                                        type_err(c, "info: variable '%v' was set as %1 here.",
                                                 cast(var, b->left)->var->where_set, t, rules, NULL);
                } else {
-                       t = propagate_types(b->right, c, perr, NULL, Rnolabel);
+                       t = propagate_types(b->right, c, perr, NULL, 0);
                        if (t)
                                propagate_types(b->left, c, perr, t,
                                                (b->op == Assign ? Rnoconstant : 0));