From 5a5e3e2de5839bcaf36a5eb73354f33f86e46f45 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 15 Apr 2024 17:50:41 +0300 Subject: fix inits --- src/actualize.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/actualize.c') diff --git a/src/actualize.c b/src/actualize.c index 7bb4e55..0c9d09e 100644 --- a/src/actualize.c +++ b/src/actualize.c @@ -2167,6 +2167,7 @@ static int actualize_dot(struct act_state *state, id); if (exists) { assert(exists->t); + exists->uses++; set_type(node, exists->t); return 0; } @@ -2234,18 +2235,15 @@ static int actualize_init(struct act_state *state, struct init_helper arg = vect_at(struct init_helper, init_args, ai); - struct init_helper mem = {0}; - foreach_vec(mi, struct_members) { - mem = vect_at(struct init_helper, struct_members, mi); - if (same_id(mem.id, arg.id)) - goto ok; - } + struct init_helper mem = vect_at(struct init_helper, struct_members, + ai); - semantic_error(scope->fctx, arg.n, "unknown argument %s", - arg.id); - goto err; + /* not the best error message but works for now */ + if (!same_id(arg.id, mem.id)) { + semantic_error(scope->fctx, node, "malformed init"); + goto err; + } -ok: if (!types_match(arg.n->t, mem.n->t)) { type_mismatch(scope, "init type mismatch", arg.n, arg.n->t, mem.n->t); @@ -2344,6 +2342,7 @@ static int actualize_fetch(struct act_state *state, struct scope *scope, return -1; } + member->uses++; set_type(fetch, member->t); return 0; } -- cgit v1.3