harec

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

commit 2b6425aeac1d91fd4c34062b762042e8f5fd1b7e
parent 9062c3682fb11aa1b11050eb91da9bcf38299986
Author: Ember Sawady <ecs@d2evs.net>
Date:   Mon,  6 Feb 2023 16:34:23 +0000

Don't crash on terminating exprs as initializers

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

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

diff --git a/src/gen.c b/src/gen.c @@ -1146,7 +1146,7 @@ gen_expr_binding(struct gen_context *ctx, const struct expression *expr) continue; } - const struct type *type = binding->initializer->result; + const struct type *type = binding->object->type; struct gen_binding *gb = xcalloc(1, sizeof(struct gen_binding)); gb->value.kind = GV_TEMP; gb->value.type = type; diff --git a/tests/26-regression.ha b/tests/26-regression.ha @@ -99,4 +99,9 @@ export fn main() void = { type b = struct { a }; def A = b { c = 0 };" ) as rt::exited != rt::EXIT_SUCCESS); + assert(rt::compile(" + fn a() void = { + let x: (void | int) = abort(); + };" + ) as rt::exited == rt::EXIT_SUCCESS); };