E102

Error

Syntax and structure

E102 — A name declared twice

Two declarations with one name in one scope: two stores, two constants, a state and a derived of one name. It compiled to a script the browser refused, or let the second quietly replace the first.

What the compiler said

error[E102]: `count` is declared twice: as a state at line 2, and as a `derived` here --> src/App.wf:3:5 | 3 | derived count = 1 | ^^^^^^^ = help: A name means one thing — rename one of the two `count`s = note: `count` is first declared here at src/App.wf:2:5 = docs: https://webfluent.monzeromer.dev/errors/E102

The fix

Broken

wf

page P(path: "/", title: "T", description: "D") { state count = 0 derived count = 1 Heading("Count {count}").h1 }

Fixed

wf

page P(path: "/", title: "T", description: "D") { state count = 0 derived doubled = count * 2 Heading("Count {count}, doubled {doubled}").h1 }

Rename one of the two. The finding points at the second and names where the first is.

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.