Allow any numeric range to become a float

Currently things like `1 / 200` lead to a miscompilation because we type
`200` (and as a result, both `1` and the division result) as a ranged
number with width >= U8. During mono that forces the number to become an
`I64` because our logic was that a ranged number can only become a float
if it's at least as wide as an I8. But this is incorrect; as long as the
type is wrapped in `Frac` constructor and it's a ranged number (and not
a ranged int), it should become a fractional type.

```
» 1 / 200

0.005 : Float *
```

Closes #4047
This commit is contained in:
Ayaz Hafiz 2022-09-16 10:05:43 -05:00
parent 57681be542
commit a81d4d4be2
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 19 additions and 1 deletions

View file

@ -2181,7 +2181,7 @@ pub fn is_any_float_range(subs: &Subs, var: Variable) -> bool {
let content = subs.get_content_without_compacting(var);
matches!(
content,
RangedNumber(NumAtLeastEitherSign(I8) | NumAtLeastSigned(I8)),
RangedNumber(NumAtLeastEitherSign(..) | NumAtLeastSigned(..)),
)
}