From b7eebe5d004380dec34a185bca6e5e343589de69 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 14 Dec 2018 18:36:06 +0000 Subject: Fix polymorphic record types with constant value parameters --- src/types.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/types.cpp') 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); } -- cgit v1.2.3