T07
Error
Types
T07 — A condition that is always true
A list, a record or an action used as a condition: it is never false, so the branch always runs.
What the compiler said
error[T07]: `if` reads `items` as a condition, but a list is always true --> src/App.wf:4:5 | 4 | if items { Text("There are items") } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: Ask about its length: `items.length > 0` = docs: https://webfluent.monzeromer.dev/errors/T07
The fix
Broken
page P(path: "/", title: "T", description: "D") {
state items = ["a"]
Heading("List").h1
if items { Text("There are items") }
}
Fixed
page P(path: "/", title: "T", description: "D") {
state items = ["a"]
Heading("List").h1
if items.length > 0 { Text("There are items") }
}
Ask the question you mean: items.length > 0, user != null.
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.