diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-04-15 17:50:41 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-04-15 17:50:41 +0300 |
| commit | 5a5e3e2de5839bcaf36a5eb73354f33f86e46f45 (patch) | |
| tree | 6b994616e35fef2dfea0a0ecab8b9f59529394a2 /src/actualize.c | |
| parent | 1b58c86d6856339d71bfc124fc8f48fbd2b09fd0 (diff) | |
| download | ek-5a5e3e2de5839bcaf36a5eb73354f33f86e46f45.tar.gz ek-5a5e3e2de5839bcaf36a5eb73354f33f86e46f45.zip | |
fix inits
Diffstat (limited to 'src/actualize.c')
| -rw-r--r-- | src/actualize.c | 19 |
1 files changed, 9 insertions, 10 deletions
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; } |
