diff --git a/lang/src/son.rs b/lang/src/son.rs index 09b4c677..71693b2a 100644 --- a/lang/src/son.rs +++ b/lang/src/son.rs @@ -3648,18 +3648,15 @@ impl<'a> Codegen<'a> { self.tys, )) } - Expr::Directive { name: "itf", args: [expr], .. } => { + Expr::Directive { name: "itf", args: [expr], pos } => { let mut val = self.expr_ctx(expr, Ctx::default().with_ty(ty::Id::INT))?; - let (ret_ty, expected) = match val.ty.simple_size().unwrap() { - 8 => (ty::Id::F64, ty::Id::INT), - _ => (ty::Id::F32, ty::Id::INT), - }; + inference!(fty, ctx, self, pos, "float", "@as())"); - self.assert_ty(expr.pos(), &mut val, expected, "converted integer"); + self.assert_ty(expr.pos(), &mut val, ty::Id::INT, "converted integer"); Some(self.ci.nodes.new_node_lit( - ret_ty, + fty, Kind::UnOp { op: TokenKind::Float }, [VOID, val.id], self.tys, diff --git a/lang/src/ty.rs b/lang/src/ty.rs index 6dfb1adb..107d4ab0 100644 --- a/lang/src/ty.rs +++ b/lang/src/ty.rs @@ -223,6 +223,7 @@ impl Id { _ if oa == ob => oa, _ if ob.is_optional() => ob, _ if oa.is_pointer() && ob.is_pointer() => return None, + _ if oa == Id::BOOL && ob.is_integer() => ob, _ if a.is_signed() && b.is_signed() || a.is_unsigned() && b.is_unsigned() => ob, _ if a.is_unsigned() && b.is_signed() && a.repr() - U8 < b.repr() - I8 => ob, _ if a.is_unsigned() && b.is_signed() && a.repr() - U8 > b.repr() - I8 => oa,