harec

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

commit 1614840282cd58338d88bf7c4c216d142b87e14b
parent fe734cfc03881aaa6011b7fae7dc5a6c9ef416ba
Author: Ember Sawady <ecs@d2evs.net>
Date:   Tue, 22 Nov 2022 00:07:35 +0000

Fix issues with global type inference

Flexible constant types keep references into the expressions they're in,
lower them in order to avoid keeping those stale references around

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

Diffstat:
Msrc/check.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/check.c b/src/check.c @@ -3332,7 +3332,7 @@ check_global(struct context *ctx, && adecl->type->array.contextual; if (context || !type) { // XXX: Do we need to do anything more here - type = initializer->result; + type = lower_const(initializer->result, NULL); } initializer = lower_implicit_cast(type, initializer); @@ -3566,7 +3566,7 @@ scan_const(struct context *ctx, const struct ast_global_decl *decl) && decl->type->array.contextual; if (context || !decl->type) { // XXX: Do we need to do anything more here - type = initializer->result; + type = lower_const(initializer->result, NULL); } char *typename1 = gen_typename(initializer->result); @@ -3647,7 +3647,7 @@ scan_global(struct context *ctx, const struct ast_global_decl *decl) struct expression *initializer = xcalloc(1, sizeof(struct expression)); check_expression(ctx, decl->init, initializer, type); - type = initializer->result; + type = lower_const(initializer->result, NULL); assert(type); free(initializer); }