]> ocean-lang.org Git - ocean/commitdiff
oceani: Improve Rboolok handling.
authorNeilBrown <neil@brown.name>
Fri, 12 Nov 2021 23:00:47 +0000 (10:00 +1100)
committerNeilBrown <neil@brown.name>
Sat, 13 Nov 2021 22:50:58 +0000 (09:50 +1100)
When Rboolok, Tnone is also allowed.
When not Rboolok, and type is not Tnone, it is only the final
statement of a block that *must* return a value.

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

index fabfe188c07ebd5bc9abdca9dd492aad34041de2..19c9471cec06bb1bc331f26a3e3cb4fecd1864c1 100644 (file)
@@ -1575,7 +1575,7 @@ propagation is needed.
 
 ###### ast
 
 
 ###### ast
 
-       enum val_rules {Rnolabel = 1<<0, Rboolok = 1<<1, Rnoconstant = 2<<1};
+       enum val_rules {Rnolabel = 1<<0, Rboolok = 1<<1, Rnoconstant = 1<<2};
 
 ###### format cases
        case 'r':
 
 ###### format cases
        case 'r':
@@ -3746,9 +3746,14 @@ is in-place.
 
                for (e = b; e; e = cast(binode, e->right)) {
                        t = propagate_types(e->left, c, ok, NULL, rules);
 
                for (e = b; e; e = cast(binode, e->right)) {
                        t = propagate_types(e->left, c, ok, NULL, rules);
-                       if ((rules & Rboolok) && t == Tbool)
+                       if ((rules & Rboolok) && (t == Tbool || t == Tnone))
                                t = NULL;
                                t = NULL;
-                       if (t && t != Tnone && t != Tbool) {
+                       if (t == Tnone && e->right)
+                               /* Only the final statement *must* return a value
+                                * when not Rboolok
+                                */
+                               t = NULL;
+                       if (t) {
                                if (!type)
                                        type = t;
                                else if (t != type)
                                if (!type)
                                        type = t;
                                else if (t != type)