scrml.dev v0.7.1
Reference › Errors

E-MULTI-STATEMENT-HANDLER

A bare-form event handler contains more than one statement.

Error Compile-time SPEC §4.14 (normative)

What it means

A bare-form event-handler attribute must be exactly one expression — a call (onclick=save()), an assignment (onclick=@phase = .Loading), or a single expression (onclick=@count++). Semicolon-separated statements in an attribute are rejected, because attribute position is not a statement context and the resulting code has no clear sequencing or scoping story. The same rule governs the :-shorthand body of an engine state-child.

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>
</>

How to fix

  1. Lift the body into a named function. Declare function handleClick() { … } and write onclick=handleClick(). This is the canonical fix and keeps the handler testable.
  2. For a state-child, switch to bare-body form. <Idle>…children + logic…</> hosts multiple statements where the :-shorthand cannot.

Related

Specification

Normative text: §4.14, §5.2.3, §17.7.6, §34. Spec lives at compiler/SPEC.md .

← Reference