fixing @itf type inference
Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
parent
07d4fe416a
commit
f7d5bccdd9
|
@ -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(<float-ty, @itf(<expr>))");
|
||||
|
||||
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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue