From 88d54b5afa776ae4cc7100dc30238538e509a442 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 13 Nov 2021 10:00:47 +1100 Subject: [PATCH] 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 --- csrc/oceani.mdc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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) -- 2.43.0