harec

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

commit 1df1186ec66e6ac19c494b99c9253a2fe4fd8c2d
parent 25842ee8d72f63351c51be65ce457a568c2be59d
Author: Ember Sawady <ecs@d2evs.net>
Date:   Wed,  1 Feb 2023 21:33:59 +0000

Don't crash on compile-time non-exhaustive structs

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

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

diff --git a/src/check.c b/src/check.c @@ -2788,10 +2788,10 @@ check_expr_struct(struct context *ctx, } if (stype) { + expr->result = stype; if (!expr->_struct.autofill) { check_struct_exhaustive(ctx, aexpr, expr, stype); } - expr->result = stype; } else { expr->result = type_store_lookup_atype(ctx->store, &satype); diff --git a/tests/26-regression.ha b/tests/26-regression.ha @@ -83,4 +83,11 @@ export fn main() void = { ) as rt::exited != rt::EXIT_SUCCESS); assert(rt::compile("let a;") as rt::exited != rt::EXIT_SUCCESS); + assert(rt::compile(" + type a = struct { + b: int, + c: int, + }; + def A: a = a { b = 0 };" + ) as rt::exited != rt::EXIT_SUCCESS); };