U10
Warning
Declared and never read
U10 — An else no value reaches
Every case of the enum has its own arm, so the match's else never runs.
What the compiler said
warning[U10]: every case of `Tone` has its own arm, so this `match`'s `else` is never reached --> src/App.wf:5:5 | 5 | match tone { | ^^^^^ = help: Remove the `else` = docs: https://webfluent.monzeromer.dev/errors/U10
The fix
Broken
enum Tone { calm, loud }
page P(path: "/", title: "T", description: "D") {
state tone: Tone = .calm
Heading("Tone").h1
match tone {
.calm { Text("Calm") }
.loud { Text("Loud") }
else { Text("?") }
}
}
Fixed
enum Tone { calm, loud }
page P(path: "/", title: "T", description: "D") {
state tone: Tone = .calm
Heading("Tone").h1
match tone {
.calm { Text("Calm") }
.loud { Text("Loud") }
}
}
Remove the else.
Each example is a whole program: it is all of src/App.wf in a project with no other .wf file (trying an example).
lints may lower it:
"lints": { "U10": "off" }
// wf-allow(U10)