E0122An idiom of another language in an enum or
ErrorUnsafe fix
An idiom of another language in an enum or match
ErrorUnsafe fixSisu writes an enum and a match its own way: match, not switch; an arm is pattern => body, with no case; the catch-all arm is _ =>, not default: or else =>; an arm uses =>, not ->; an enum is enum Name, not enum class Name; and a variant is Name.Variant, not Name::Variant.
Why
Each of these forms is right in some other language, and each has one spelling in Sisu, so the fix is the Sisu spelling. Replacing switch and deleting case are unsafe fixes: the rest of the construct may still be written the other language's way.
Broken
enum State {
Idle
Busy
}
fn main() {
for s in [State.Idle, State.Busy] {
let n = switch s {
Idle => 0
Busy => 1
}
print(n)
}
}
What sisu says
error[E0122]: Sisu writes `match` --> E0122.sisu:8:17 | 8 | let n = switch s { | ^^^^^^ | help: write `match` | 8 - let n = switch s { 8 + let n = match s { | sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0122
Fixed
enum State {
Idle
Busy
}
fn main() {
for s in [State.Idle, State.Busy] {
let n = match s {
Idle => 0
Busy => 1
}
print(n)
}
}
Sisu