mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-24 06:55:15 +00:00
Recover default layouts for floats
This commit is contained in:
parent
4ef8ceef9e
commit
26148b8b12
2 changed files with 13 additions and 2 deletions
|
@ -1208,6 +1208,16 @@ pub fn is_unresolved_var(subs: &Subs, var: Variable) -> bool {
|
|||
)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn is_any_float_range(subs: &Subs, var: Variable) -> bool {
|
||||
use {roc_types::num::IntLitWidth::*, Content::*, NumericRange::*};
|
||||
let content = subs.get_content_without_compacting(var);
|
||||
matches!(
|
||||
content,
|
||||
RangedNumber(NumAtLeastEitherSign(I8) | NumAtLeastSigned(I8)),
|
||||
)
|
||||
}
|
||||
|
||||
impl<'a> Layout<'a> {
|
||||
pub const VOID: Self = Layout::Union(UnionLayout::NonRecursive(&[]));
|
||||
pub const UNIT: Self = Layout::Struct {
|
||||
|
@ -1255,7 +1265,8 @@ impl<'a> Layout<'a> {
|
|||
}
|
||||
|
||||
Symbol::NUM_FRAC | Symbol::NUM_FLOATINGPOINT
|
||||
if is_unresolved_var(env.subs, actual_var) =>
|
||||
if is_unresolved_var(env.subs, actual_var)
|
||||
|| is_any_float_range(env.subs, actual_var) =>
|
||||
{
|
||||
// default to f64
|
||||
return Ok(Layout::f64());
|
||||
|
|
|
@ -594,7 +594,7 @@ fn check_and_merge_valid_range<M: MetaCollector>(
|
|||
merge_if!(range.contains_int_width(IntLitWidth::U128))
|
||||
}
|
||||
|
||||
Symbol::NUM_DEC => {
|
||||
Symbol::NUM_DEC | Symbol::NUM_DECIMAL => {
|
||||
merge_if!(range.contains_float_width(FloatWidth::Dec))
|
||||
}
|
||||
Symbol::NUM_F32 | Symbol::NUM_BINARY32 => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue