aboutsummaryrefslogtreecommitdiff
path: root/src/type.cff
diff options
context:
space:
mode:
Diffstat (limited to 'src/type.cff')
-rw-r--r--src/type.cff18
1 files changed, 6 insertions, 12 deletions
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;
}