scrml.dev v0.8.0
E-MULTI-STATEMENT-HANDLER · scrml error reference
Reference › Errors

E-MULTI-STATEMENT-HANDLER

An unbraced event handler contains a ;-separated sequence of statements.

Error Compile-time SPEC §5.2.3 (normative)

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

  1. 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.
  2. Or name a function when the logic is reused or reads better with a name: function handleClick() { … } and onclick=handleClick(). Both forms are a free choice.
  3. 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 .

← Reference