T11
Error
Types
T11 — A match on something that cannot be matched
A match is over a read, a result, a connection or an enum; its arms are the cases of that kind.
What the compiler said
error[T11]: `match` needs a resource or an enum, but `n` is `Number` --> src/App.wf:4:5 | 4 | match n { | ^^^^^^^^^ = help: Use `if` for a condition; `match` chooses among a resource's states or an enum's cases = docs: https://webfluent.monzeromer.dev/errors/T11
The fix
Broken
page P(path: "/", title: "T", description: "D") {
state n = 1
Heading("Match").h1
match n {
.loading { Spinner }
else { Text("?") }
}
}
Fixed
page P(path: "/", title: "T", description: "D") {
state n = 1
Heading("Match").h1
if n == 1 { Text("One") } else { Text("?") }
}
Use if for a condition; match takes a read (a resource), a result (.ok, .err), a connection or an enum.
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.