From a90cecd0016cf35d400d6de895f1b2aa6c5ac0dd Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 17 Dec 2021 15:20:54 +1100 Subject: [PATCH 1/1] oceani: propagate_type should return the found type, not what it was compatible with If the type we have is different from the type expected, but they are compatible, propagate_type() should return the type that we have. Otherwise we lose information - which may later be useful. Signed-off-by: NeilBrown --- csrc/oceani-tests.mdc | 2 ++ csrc/oceani.mdc | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/csrc/oceani-tests.mdc b/csrc/oceani-tests.mdc index 50a26df..1a36534 100644 --- a/csrc/oceani-tests.mdc +++ b/csrc/oceani-tests.mdc @@ -967,9 +967,11 @@ 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: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:27:16: error: expected number found string .tmp.code:28:16: error: expected string found Boolean diff --git a/csrc/oceani.mdc b/csrc/oceani.mdc index a625348..c80c992 100644 --- a/csrc/oceani.mdc +++ b/csrc/oceani.mdc @@ -2293,9 +2293,7 @@ correctly. *perr |= Eruntime; if (v->constant) *perr |= Econst; - if (!type) - return v->type; - return type; + return v->type; } ###### interp exec cases @@ -4803,7 +4801,8 @@ be declared at any time. return Tnone; if (t) { - if (propagate_types(b->right, c, perr_local, t, 0) != 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); -- 2.43.0