aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-25 13:13:09 +0200
committerlemon <lsof@mailbox.org>2022-08-25 13:13:09 +0200
commit9eeb4f4641481279895a927f97503d7a6938b2e5 (patch)
tree335e50f8a479653e4f513e6ba5daa8fe32144de5
parent90a57be9d1cf811ba26c09d6c8ac9f27067a5f85 (diff)
fix voidness eq issue
-rw-r--r--src/common.hff5
-rw-r--r--src/type.cff18
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;
}