integer constants can be casted to floats if type is known to be a float
This commit is contained in:
parent
63a1c7feb4
commit
c657084451
|
@ -2486,6 +2486,12 @@ impl<'a> Codegen<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expr::Bool { value, .. } => Some(self.ci.nodes.new_const_lit(ty::Id::BOOL, value)),
|
Expr::Bool { value, .. } => Some(self.ci.nodes.new_const_lit(ty::Id::BOOL, value)),
|
||||||
|
Expr::Number { value, .. }
|
||||||
|
if let Some(ty) = ctx.ty
|
||||||
|
&& ty.is_float() =>
|
||||||
|
{
|
||||||
|
Some(self.ci.nodes.new_const_lit(ty, (value as f64).to_bits() as i64))
|
||||||
|
}
|
||||||
Expr::Number { value, .. } => Some(
|
Expr::Number { value, .. } => Some(
|
||||||
self.ci.nodes.new_const_lit(
|
self.ci.nodes.new_const_lit(
|
||||||
ctx.ty
|
ctx.ty
|
||||||
|
|
Loading…
Reference in a new issue