diff options
Diffstat (limited to 'bootstrap/types.c')
| -rw-r--r-- | bootstrap/types.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/bootstrap/types.c b/bootstrap/types.c index 66ae840..37977ea 100644 --- a/bootstrap/types.c +++ b/bootstrap/types.c @@ -301,6 +301,16 @@ constifychild(const struct type *ty) { return interntype(ty2); } +const struct type * +unconstifychild(const struct type *ty) { + struct type ty2 = *ty; + const struct type *child = unconstify(ty->child); + if (child == ty->child) + return ty; + ty2.child = child; + return interntype(ty2); +} + static const struct type * arraydecay(const struct type *ty) { struct type ty2 = *ty; @@ -367,7 +377,7 @@ typeof2(const struct type *a, const struct type *b) { b = arraydecay(b); if (a->t == TYarr && b->t == TYptr) a = arraydecay(a); - if (a->t == TYptr && b->t == TYptr) { + if (a->t == b->t && (a->t == TYptr || a->t == TYslice)) { bool akonst = a->child->konst, bkonst = b->child->konst; const struct type *uac = unconstify(a->child), @@ -396,6 +406,7 @@ typeof2(const struct type *a, const struct type *b) { } } + return NULL; } |