From 1eb17cda6780476b166b55d0fedc3ad355969e87 Mon Sep 17 00:00:00 2001 From: lemon Date: Fri, 12 Aug 2022 16:43:06 +0200 Subject: selfhosted lexer --- bootstrap/types.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'bootstrap/types.c') 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; } -- cgit v1.2.3