scrml.dev v0.7.1
Reference › Errors

E-ENGINE-EFFECT-AMBIGUOUS

effect= on a state-child whose rule= has multiple targets.

Error Compile-time SPEC §51.0.H (normative)

What it means

effect= attaches one side effect to one transition. When rule= names several possible targets, the compiler cannot tell which transition the effect belongs to — running it on all of them and running it on one are both defensible readings, so it refuses to choose. Single-target rules keep effect= unambiguous.

Minimal reproducer

This is the exact source compiled against the linked compiler and verified to produce E-ENGINE-EFFECT-AMBIGUOUS.

<program title="p">
    type Phase:enum = { Idle, Busy, Done }
    function ping() { return 1 }
    <engine for=Phase initial=.Idle>
        <Idle rule=(.Busy | .Done) effect=${ping()}>idle</>
        <Busy rule=(.Done)>busy</>
        <Done rule=(.Idle)>done</>
    </>
</>

How to fix

  1. Use <onTransition to=…> children. This is the canonical multi-target form: one child per transition, each with its own body. Explicit about which effect belongs to which edge.
  2. Narrow the rule to a single target. If the state really only transitions one way, effect= is fine once rule= reflects that.

Related

Specification

Normative text: §51.0.H, §55.15, §34. Spec lives at compiler/SPEC.md .

← Reference