Math written another way
ErrorSafe fixOther languages write math as Math.sqrt(x), math.pi or Math.PI, and Sisu does not. Math in Sisu is methods and constants on f64: x.sqrt() and f64.pi. The error points at the math. or Math. form that a method or constant of f64 replaces. It also covers f64.max(a, b), which is the method call a.max(b).
The fix is safe, because it checks. A constant is always safe: math.pi, Math.PI and math.inf become f64.pi and f64.infinity, whatever the case. A method call is safe when its first argument has the method, and the other arguments are the method's parameters. Otherwise there is no fix: math.sqrt(n) with n: i64 has no method to call, and math.sqrt(x, 2.0) has an argument too many. There is also no fix when the rewrite would delete a comment inside the call.
Why
A method belongs to the value it works on. x.sqrt() reads left to right, and the value says which sqrt it is. There is no math module in Sisu, so math and Math are ordinary names. A local called math is a value, and its members are its own. With no such name, math.foo is E0033.
Broken
fn main() {
let x = 2.0
print(math.sqrt(x))
}
What sisu says
error[E0106]: math in Sisu is methods and constants on `f64` --> E0106.sisu:3:11 | 3 | print(math.sqrt(x)) | ^^^^^^^^^ | help: write `x.sqrt()` | 3 - print(math.sqrt(x)) 3 + print(x.sqrt()) | sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0106
Fixed
fn main() {
let x = 2.0
print(x.sqrt())
}
Sisu