From 9eeb4f4641481279895a927f97503d7a6938b2e5 Mon Sep 17 00:00:00 2001 From: lemon Date: Thu, 25 Aug 2022 13:13:09 +0200 Subject: fix voidness eq issue --- src/common.hff | 5 ----- src/type.cff | 18 ++++++------------ 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/common.hff b/src/common.hff index 6b63334..a54fd32 100644 --- a/src/common.hff +++ b/src/common.hff @@ -38,11 +38,6 @@ defmacro foreach_ptr(x, i, a, &body) [ defmacro streq(a,b) [ (strcmp(a,b) == 0) ] defmacro strcieq(a,b) [ (strcasecmp(a,b) == 0) ] -defmacro coalesce(a,b) [ - (do let $x = a; - $x ? $x : b; ) -] - defmacro with_tmpchange(var,x,&body) [ { let $tmp = (var); (var) = x; diff --git a/src/type.cff b/src/type.cff index d93548a..c0fe157 100644 --- a/src/type.cff +++ b/src/type.cff @@ -7,7 +7,7 @@ struct TypeTraits { fn hash(ty *const Type) u32 { let h = FNV1A_INI; h = fnv1a_i(h, as(int)ty.u.#tag); - h *= as(int)ty.konst + 2; + h = fnv1a_i(h, as(int)ty.konst); switch ty.u { case Void; @@ -54,6 +54,7 @@ struct TypeTraits { } switch a.u { case Void; + return #t; case Bool; return a.size == b.size; case Flo; @@ -243,18 +244,11 @@ fn arraydecay(ty *const Type) *const Type { } fn constifychild(ty *const Type) *const Type { - let ty2 = *ty; switch ty.u { case Ptr child; - let cchild = constify(child); - if child == cchild { return ty; } - ty2.u.Ptr = child; - return interntype(ty2); + return mkptrtype(constify(child)); case Slice child; - let cchild = constify(child); - if child == cchild { return ty; } - ty2.u.Slice = child; - return interntype(ty2); + return mkslicetype(constify(child)); case else; assert(#f, "constifychild: not ptr or slice"); } @@ -295,11 +289,11 @@ extern fn typeof2(a *const Type, b *const Type) *const Type { if uac == ubc { return akonst ? a : b; } - if uac->is(:Void) { + if uac == ty_void { if !bkonst and akonst { return constifychild(b); } return b; } - if ubc->is(:Void) { + if ubc == ty_void { if !akonst and bkonst { return constifychild(a); } return a; } -- cgit v1.2.3