From: NeilBrown Date: Fri, 12 Nov 2021 23:00:47 +0000 (+1100) Subject: oceani: Improve Rboolok handling. X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=commitdiff_plain;h=88d54b5afa776ae4cc7100dc30238538e509a442 oceani: Improve Rboolok handling. 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 --- diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index fabfe18..19c9471 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -1575,7 +1575,7 @@ propagation is needed. ###### 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': @@ -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); - if ((rules & Rboolok) && t == Tbool) + if ((rules & Rboolok) && (t == Tbool || t == Tnone)) 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)