harec

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

commit 5abd8e6b0525b1c6be004bca38b41e5f5cb36459
parent fc39782822761a78ec6f3e449dba6583ae33909f
Author: Ember Sawady <ecs@d2evs.net>
Date:   Mon,  6 Feb 2023 16:34:20 +0000

Don't abort on compile-time cast to error/void

Fixes: https://todo.sr.ht/~sircmpwn/hare/789
Signed-off-by: Ember Sawady <ecs@d2evs.net>

Diffstat:
Msrc/eval.c | 2+-
Mtests/26-regression.ha | 1+
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/eval.c b/src/eval.c @@ -650,7 +650,7 @@ eval_cast(struct context *ctx, struct expression *in, struct expression *out) assert(0); // Invariant case STORAGE_ERROR: case STORAGE_VOID: - break; // no-op + return EVAL_OK; } assert(0); // Unreachable diff --git a/tests/26-regression.ha b/tests/26-regression.ha @@ -92,4 +92,5 @@ export fn main() void = { ) as rt::exited != rt::EXIT_SUCCESS); assert(rt::compile("let a = &0;") as rt::exited != rt::EXIT_SUCCESS); assert(rt::compile("def A: a = 1 % 1;") as rt::exited != rt::EXIT_SUCCESS); + assert(rt::compile("def A: b = void;") as rt::exited != rt::EXIT_SUCCESS); };