]> ocean-lang.org Git - ocean/commitdiff
oceani: move the 'info:' report for assignments.
authorNeilBrown <neil@brown.name>
Fri, 17 Dec 2021 04:55:43 +0000 (15:55 +1100)
committerNeilBrown <neil@brown.name>
Fri, 17 Dec 2021 04:55:43 +0000 (15:55 +1100)
When we provide info about where the type of the assigned variable was
set, make sure that happens *after* any error was reported.

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

index 1a36534abf4ba13b6079e4f80ecc22132ecc1b46..8256950487daa5c37a3fbe1961a09e23ac686de8 100644 (file)
@@ -957,6 +957,7 @@ various places that `type_err()` are called.
        .tmp.code:8:12: error: Arithmetic returns number but string expected
        .tmp.code:7:8: info: variable 'c' was set as string here.
        .tmp.code:9:24: error: Boolean operation found where string expected
+       .tmp.code:7:8: info: variable 'c' was set as string here.
        .tmp.code:10:12: error: Comparison returns Boolean but string expected
        .tmp.code:7:8: info: variable 'c' was set as string here.
        .tmp.code:11:21: error: Concat returns string but number expected
@@ -967,12 +968,12 @@ various places that `type_err()` are called.
        .tmp.code:24:8: error: cannot assign value of type [5]number
        .tmp.code:25:13: error: expected [5]number but variable 'a3' is [10]number
        .tmp.code:23:36: info: this is where 'a3' was set to [10]number
-       .tmp.code:23:8: info: variable 'a1' was set as [5]number here.
        .tmp.code:25:8: error: cannot assign value of type [5]number
+       .tmp.code:23:8: info: variable 'a1' was set as [5]number here.
        .tmp.code:26:13: error: expected [5]number but variable 'a4' is [5]string
        .tmp.code:23:51: info: this is where 'a4' was set to [5]string
-       .tmp.code:23:8: info: variable 'a1' was set as [5]number here.
        .tmp.code:26:8: error: cannot assign value of type [5]number
+       .tmp.code:23:8: info: variable 'a1' was set as [5]number here.
        .tmp.code:27:16: error: expected number found string
        .tmp.code:28:16: error: expected string found Boolean
        .tmp.code:29:12: error: have number but need string
index c80c99262004c6b39f82ca924e7e513fb3fddfaf..0605d97b4a82918ddf952f1cbb761748d8855a32 100644 (file)
@@ -4801,11 +4801,7 @@ be declared at any time.
                        return Tnone;
 
                if (t) {
-                       if (propagate_types(b->right, c, perr_local, t, 0) != t &&
-                           *perr_local & Efail)
-                               if (b->left->type == Xvar)
-                                       type_err(c, "info: variable '%v' was set as %1 here.",
-                                                cast(var, b->left)->var->where_set, t, rules, NULL);
+                       propagate_types(b->right, c, perr_local, t, 0);
                } else {
                        t = propagate_types(b->right, c, perr_local, NULL, 0);
                        if (t)
@@ -4826,6 +4822,9 @@ be declared at any time.
                }
                if (t && t->dup == NULL && !(*perr_local & Emaycopy))
                        type_err(c, "error: cannot assign value of type %1", b, t, 0, NULL);
+               if (b->left->type == Xvar && (*perr_local & Efail))
+                       type_err(c, "info: variable '%v' was set as %1 here.",
+                                cast(var, b->left)->var->where_set, t, rules, NULL);
                return Tnone;
 
                break;