aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/types.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-12 16:43:06 +0200
committerlemon <lsof@mailbox.org>2022-08-12 16:43:06 +0200
commit1eb17cda6780476b166b55d0fedc3ad355969e87 (patch)
treeccb4ffa74cc37f24e93d4325ccf395d3fe73529f /bootstrap/types.c
parentf14aee6184568bae34f8d8d8f9140fa760099fa5 (diff)
selfhosted lexer
Diffstat (limited to 'bootstrap/types.c')
-rw-r--r--bootstrap/types.c13
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;
}