E-MULTI-STATEMENT-HANDLER
An unbraced event handler contains a
;-separated sequence of statements.
What it means
A handler that does several things is fine — write it as an
inline block in braces:
onclick={ @count++; @flag = true }. That form is legal and
canonical (as of v0.8.0). What stays an error is the same sequence written
without braces: a bare (unbraced) handler value must be exactly one
expression — a call (onclick=save()), an assignment
(onclick=@phase = .Loading), or a single expression
(onclick=@count++). A ; in a bare value is
E-MULTI-STATEMENT-HANDLER. The :-shorthand body of an
engine state-child is still single-expression too.
Minimal reproducer
This is the exact source compiled against the linked compiler and verified to produce E-MULTI-STATEMENT-HANDLER.
<program title="p">
<count> = 0
<flag> = false
<button onclick=@count++; @flag = true>go</button>
<p>${@count}</p>
</>
The same handler with braces compiles:
<program title="p">
<count> = 0
<flag> = false
<button onclick={ @count++; @flag = true }>go</button>
<p>${@count} ${@flag}</p>
</>
How to fix
-
Wrap the statements in braces.
<button onclick={ @count++; @flag = true }>go</button>— the statements run in order, each once, every time the event fires. This is the canonical fix. -
Or name a function when the logic is reused or reads
better with a name:
function handleClick() { … }andonclick=handleClick(). Both forms are a free choice. -
For a state-child, switch to bare-body form.
<Idle>…children + logic…</>hosts multiple statements where the:-shorthand cannot.
Related
Specification
Normative text: §5.2.3, §4.14, §17.7.6, §34. Spec lives at compiler/SPEC.md .