commit b531ec97986afecdf66d799b78c2a556761b2761
parent 270a31d4ff340c1d0d374f87bc2979580385fed5
Author: Armin Weigl <tb46305@gmail.com>
Date: Mon, 5 Apr 2021 17:55:08 +0000
check_expr_for: dealias condition
Diffstat:
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/check.c b/src/check.c
@@ -1483,7 +1483,7 @@ check_expr_for(struct context *ctx,
errors = check_expression(ctx, aexpr->_for.cond, cond,
&builtin_type_bool, errors);
expr->_for.cond = cond;
- if (cond->result->storage != STORAGE_BOOL) {
+ if (type_dealias(cond->result)->storage != STORAGE_BOOL) {
return error(aexpr->_for.cond->loc, expr, errors,
"Expected for condition to be boolean");
}
diff --git a/tests/12-loops.ha b/tests/12-loops.ha
@@ -97,6 +97,15 @@ fn label() void = {
assert(rt::compile("fn test() void = { :foo for (true) { :foo for (true) void; } ; };") != 0);
};
+type abool = bool;
+
+fn alias() void = {
+ for (true: abool) {
+ return;
+ };
+ abort("unreachable");
+};
+
export fn main() void = {
scope();
conditional();
@@ -105,4 +114,5 @@ export fn main() void = {
_break();
_continue();
label();
+ alias();
};