E0101Float without digits on both sides of
ErrorSafe fix
Float without digits on both sides of .
ErrorSafe fixA float literal has at least one digit before its . and at least one after it: 1.0 and 0.5. 1. and .5 are errors.
Why
A . belongs to a number only when a digit follows it, so that 0..n is a range and 1.max(2) is a method call on 1. That leaves 1. with nothing to tell it from a call that lost its method name, and .5 with nothing to tell it from a field read that lost its object. Writing the 0 says which one you mean. The fix writes the missing 0, after the . in 1. and before it in .5, and nothing else, so it is safe.
Broken
fn main() {
let x = 1.
print(x)
}
What sisu says
error[E0101]: a float needs digits on both sides of `.` --> E0101.sisu:2:14 | 2 | let x = 1. | ^ | help: write a `0` after the `.` | 2 | let x = 1.0 | + sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0101
Fixed
fn main() {
let x = 1.0
print(x)
}
Sisu