U06
Warning
Declared and never read
U06 — Code after return
What follows a return in the same block never runs.
What the compiler said
warning[U06]: this never runs: the `return` above leaves first --> src/App.wf:6:9 | 6 | log("reset") | ^^^^^^^^^^^^ = help: Remove it, or move it above the `return` = docs: https://webfluent.monzeromer.dev/errors/U06
Your editor offers this fix: Remove what never runs. wf fix --code U06 applies it to every place it fits.
The fix
Broken
page P(path: "/", title: "T", description: "D") {
state n = 0
action reset() -> Number {
n = 0
return n
log("reset")
}
Heading("Count {n}").h1
Button("Reset") { on click { reset() } }
}
Fixed
page P(path: "/", title: "T", description: "D") {
state n = 0
action reset() -> Number {
n = 0
log("reset")
return n
}
Heading("Count {n}").h1
Button("Reset") { on click { reset() } }
}
Remove it, or move it above the return.
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": { "U06": "off" }
// wf-allow(U06)