harec

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

commit 904a631e6d7ca10ef820c136afe496f1a4b6b8eb
parent b6cb76a4dcaba027ca45436106978e35dd6f568a
Author: Ember Sawady <ecs@d2evs.net>
Date:   Tue, 31 Jan 2023 22:28:13 +0000

Fail gracefully on compile-time &invalid_expr

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

Diffstat:
Msrc/eval.c | 5+++++
Mtests/26-regression.ha | 7+++++++
2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/eval.c b/src/eval.c @@ -929,6 +929,11 @@ static enum eval_result eval_unarithm(struct context *ctx, struct expression *in, struct expression *out) { if (in->unarithm.op == UN_ADDRESS) { + if (in->unarithm.operand->result == &builtin_type_error) { + out->type = EXPR_CONSTANT; + out->result = &builtin_type_error; + return EVAL_OK; + } assert(in->unarithm.operand->type == EXPR_ACCESS); // TODO other access types assert(in->unarithm.operand->access.type == ACCESS_IDENTIFIER); diff --git a/tests/26-regression.ha b/tests/26-regression.ha @@ -1,4 +1,5 @@ // Miscellaneous regression tests +use rt; type embedded = struct { a: u64, @@ -74,4 +75,10 @@ export fn main() void = { case void => void; case !void => abort(); }; + + assert(rt::compile(" + fn a() void = switch (b) { + case &c => void; + };" + ) as rt::exited != rt::EXIT_SUCCESS); };