harec

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

commit 4e25b3ff44f7c7f9d356aae162482eb5cc8f1a14
parent 20eabcb853dcf2ee6b192599c68002b5560f7296
Author: Pierre Curto <pierre.curto@gmail.com>
Date:   Thu,  1 Sep 2022 18:24:02 +0200

allow alloc init with expandable array

Fixes https://todo.sr.ht/~sircmpwn/hare/657

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>

Diffstat:
Msrc/check.c | 2+-
Mtests/08-slices.ha | 3+++
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/check.c b/src/check.c @@ -337,7 +337,7 @@ check_expr_alloc_init(struct context *ctx, return; } assert(htype->array.members == atype->array.members); - objtype = hint; + objtype = htype; } expr->result = type_store_lookup_pointer(ctx->store, aexpr->loc, objtype, ptrflags); diff --git a/tests/08-slices.ha b/tests/08-slices.ha @@ -35,6 +35,9 @@ fn storage() void = { for (let i = 0z; i < len(expected); i += 1) { assert(x[i] == expected[i]); }; + + let x: *[1]u8 = alloc([0...]); + free(x); }; fn casting() void = {