harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

commit 26cee7b5ccaf8b3d8795e17c4fa489365f8cadd4
parent b2eca0f6270dbd65d42a340c7802bf66879740f6
Author: Ember Sawady <ecs@d2evs.net>
Date:   Mon,  6 Feb 2023 16:34:33 +0000

check_expr_binarithm: fix error handling

Signed-off-by: Ember Sawady <ecs@d2evs.net>

Diffstat:
Msrc/check.c | 5+++++
Mtests/26-regression.ha | 1+
2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/check.c b/src/check.c @@ -976,6 +976,7 @@ check_expr_binarithm(struct context *ctx, error(ctx, aexpr->loc, expr, "Cannot perform arithmetic on non-numeric %s type", type_storage_unparse(type_dealias(p)->storage)); + return; } expr->result = p; break; @@ -984,6 +985,7 @@ check_expr_binarithm(struct context *ctx, error(ctx, aexpr->loc, expr, "Cannot perform operation on non-integer %s type", type_storage_unparse(type_dealias(p)->storage)); + return; } expr->result = p; break; @@ -992,6 +994,7 @@ check_expr_binarithm(struct context *ctx, error(ctx, aexpr->loc, expr, "Cannot perform logical arithmetic on non-bool %s type", type_storage_unparse(type_dealias(p)->storage)); + return; } break; case BT_COMPARISON: @@ -999,6 +1002,7 @@ check_expr_binarithm(struct context *ctx, error(ctx, aexpr->loc, expr, "Cannot perform comparison on non-numeric %s type", type_storage_unparse(type_dealias(p)->storage)); + return; } break; case BT_EQUALITY: @@ -1010,6 +1014,7 @@ check_expr_binarithm(struct context *ctx, error(ctx, aexpr->loc, expr, "Cannot perform equality test on %s type", type_storage_unparse(type_dealias(p)->storage)); + return; } break; case BT_INVALID: diff --git a/tests/26-regression.ha b/tests/26-regression.ha @@ -115,4 +115,5 @@ export fn main() void = { assert(rt::compile("fn a() void = &*&a;") as rt::exited != rt::EXIT_SUCCESS); assert(rt::compile("let a = [*&0];") as rt::exited != rt::EXIT_SUCCESS); assert(rt::compile("fn a() *void = alloc(void);") as rt::exited != rt::EXIT_SUCCESS); + assert(rt::compile("fn a() void = { static let b = x & struct { a: int = 0 }; };") as rt::exited != rt::EXIT_SUCCESS); };