From 5081ea1a0c2469ed77531a6a6718a9de86f1d140 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 15 Jun 2018 19:59:35 +0100 Subject: Fix type aliasing comparison; Fix gb_utf8_decode --- src/types.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/types.cpp') diff --git a/src/types.cpp b/src/types.cpp index a28bbf608..a57058dbf 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -1157,6 +1157,19 @@ bool is_type_comparable(Type *t) { return false; } +Type *strip_type_aliasing(Type *x) { + if (x == nullptr) { + return x; + } + if (x->kind == Type_Named) { + Entity *e = x->Named.type_name; + if (e != nullptr && e->kind == Entity_TypeName && e->TypeName.is_type_alias) { + return x->Named.base; + } + } + return x; +} + bool are_types_identical(Type *x, Type *y) { if (x == y) { return true; @@ -1167,6 +1180,9 @@ bool are_types_identical(Type *x, Type *y) { return false; } + x = strip_type_aliasing(x); + y = strip_type_aliasing(y); + switch (x->kind) { case Type_Generic: if (y->kind == Type_Generic) { -- cgit v1.2.3