Fix polymorphic record types with constant value parameters

This commit is contained in:
gingerBill
2018-12-14 18:36:06 +00:00
parent 57d4333ed3
commit b7eebe5d00
5 changed files with 82 additions and 26 deletions

View File

@@ -140,10 +140,11 @@ struct TypeUnion {
Entity *type_name; /* Entity_TypeName */ \
}) \
TYPE_KIND(Generic, struct { \
i64 id; \
String name; \
Type * specialized; \
Scope *scope; \
i64 id; \
String name; \
Type * specialized; \
Scope * scope; \
Entity *entity; \
}) \
TYPE_KIND(Pointer, struct { Type *elem; }) \
TYPE_KIND(Opaque, struct { Type *elem; }) \
@@ -1988,6 +1989,15 @@ Selection lookup_field_with_selection(Type *type_, String field_name, bool is_ty
return sel;
}
}
} else if (type->kind == Type_Union) {
Scope *s = type->Union.scope;
if (s != nullptr) {
Entity *found = scope_lookup_current(s, field_name);
if (found != nullptr && found->kind != Entity_Variable) {
sel.entity = found;
return sel;
}
}
} else if (type->kind == Type_BitSet) {
return lookup_field_with_selection(type->BitSet.elem, field_name, true, sel, allow_blank_ident);
}