commit a936b477287e4288c1352a925b0439da5e14a9b8
parent f84e891ddd0cbdc6471ef97300e3a27960bf1152
Author: Bor Grošelj Simić <bgs@turminal.net>
Date: Sat, 21 May 2022 03:03:08 +0200
import members without linear scans over scope for enum values
Fixes: https://todo.sr.ht/~sircmpwn/hare/586
Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>
Diffstat:
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/check.c b/src/check.c
@@ -3789,17 +3789,20 @@ load_import(struct context *ctx, struct ast_imports *import,
!= STORAGE_ENUM) {
continue;
};
- for (struct scope_object *o = mod->objects;
+ struct scope *enum_scope =
+ type_dealias(obj->type)->_enum.values;
+ for (struct scope_object *o = enum_scope->objects;
o; o = o->lnext) {
- if (!identifier_eq(o->name.ns, &ident)) {
- continue;
+ struct identifier value_ident = {
+ .name = o->name.name,
+ .ns = &ident,
};
- struct identifier n = {
+ struct identifier value_name = {
.name = o->name.name,
.ns = &name,
};
- scope_insert(scope, o->otype, &o->ident,
- &n, o->type, o->value);
+ scope_insert(scope, o->otype, &value_ident,
+ &value_name, o->type, o->value);
};
}