commit 3798b31e30c8ad5838ba63c119531a67555cf7e3
parent b531ec97986afecdf66d799b78c2a556761b2761
Author: Armin Weigl <tb46305@gmail.com>
Date: Mon, 5 Apr 2021 17:55:09 +0000
check_expr_if: dealias condition
Diffstat:
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/check.c b/src/check.c
@@ -1582,7 +1582,7 @@ check_expr_if(struct context *ctx,
expr->terminates = false;
}
- if (cond->result->storage != STORAGE_BOOL) {
+ if (type_dealias(cond->result)->storage != STORAGE_BOOL) {
return error(aexpr->_if.cond->loc, expr, errors,
"Expected if condition to be boolean");
}
diff --git a/tests/20-if.ha b/tests/20-if.ha
@@ -58,6 +58,15 @@ fn tagged() void = {
assert((if (false) 1u8 else 0i8) as i8 == 0);
};
+type abool = bool;
+
+fn alias() void = {
+ if (true: abool) {
+ return;
+ };
+ abort("unreachable");
+};
+
export fn main() void = {
equality();
inequality();
@@ -71,4 +80,5 @@ export fn main() void = {
and();
or();
tagged();
+ alias();
};