diff options
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/types.cpp b/src/types.cpp index 262e4c228..512505007 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -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); } |