T08
Error
Types
T08 — A loop over something that is not a list
A for over a number, a string or a record.
What the compiler said
error[T08]: `for` loops over a list, but `total` is `Number` --> src/App.wf:4:5 | 4 | for n in total { Text("{n}") } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: Give it a list, or `.split(…)` a string first = docs: https://webfluent.monzeromer.dev/errors/T08
The fix
Broken
page P(path: "/", title: "T", description: "D") {
state total = 3
Heading("Loop").h1
for n in total { Text("{n}") }
}
Fixed
page P(path: "/", title: "T", description: "D") {
state total = 3
Heading("Loop").h1
for n in 1..=total { Text("{n}") }
}
Loop over a list — for n in 1..=total for a range of numbers.
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.