T15
Error
Types
T15 — A match that misses a case, or has one twice
A match with no else must give every case of the enum an arm — a value with a case it misses would match nothing. A case with two arms reaches only the first. A match expression that covers every case needs no else.
What the compiler said
error[T15]: this `match` on `status` has no arm for `.review`, and no `else` --> src/App.wf:5:5 | 5 | match status { | ^^^^^ = help: Add an arm for each, or `else { … }` for the rest = docs: https://webfluent.monzeromer.dev/errors/T15
Your editor offers this fix: Add an arm for .review. wf fix --code T15 applies it to every place it fits.
The fix
Broken
enum Status { draft, review, live }
page P(path: "/", title: "T", description: "D") {
state status: Status = .draft
Heading("Status").h1
match status {
.draft { Text("Draft") }
.live { Text("Live") }
}
}
Fixed
enum Status { draft, review, live }
page P(path: "/", title: "T", description: "D") {
state status: Status = .draft
Heading("Status").h1
match status {
.draft { Text("Draft") }
.review { Text("In review") }
.live { Text("Live") }
}
}
Give every case its arm, or add else { … } for the rest. A
match expression that covers every case needs no else:
derived label = match status { .draft { "Draft" } .review { "In review" } .live { "Live" } }.
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 cannot lower it: it would ship a broken page.