harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 8a8f11ac25f985aac5b3f2d88f0c04856826f161
parent d4847c04bca741681432426d53a9f2e01f63c7dd
Author: Armin Weigl <tb46305@gmail.com>
Date:   Mon, 24 May 2021 13:35:21 +0200

check_expr_unarithm: dealias LNOT parameter

Signed-off-by: Armin Weigl <tb46305@gmail.com>

Diffstat:
Msrc/check.c | 2+-
Atests/29-unarithm.ha | 9+++++++++
Mtests/configure | 3++-
3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/check.c b/src/check.c @@ -2492,7 +2492,7 @@ check_expr_unarithm(struct context *ctx, switch (expr->unarithm.op) { case UN_LNOT: - if (operand->result->storage != STORAGE_BOOL) { + if (type_dealias(operand->result)->storage != STORAGE_BOOL) { return error(aexpr->unarithm.operand->loc, expr, errors, "Cannot perform logical NOT (!) on non-boolean type"); } diff --git a/tests/29-unarithm.ha b/tests/29-unarithm.ha @@ -0,0 +1,9 @@ +type abool = bool; + +fn lnot() void = { + assert(!(false: abool)); +}; + +export fn main() void = { + lnot(); +}; diff --git a/tests/configure b/tests/configure @@ -31,7 +31,8 @@ tests() { 25-promotion \ 26-gen \ 27-rt \ - 28-insert + 28-insert \ + 29-unarithm do cat <<EOF tests/$t: libhart.a tests/$t.ha