E-DERIVED-ENGINE-NO-INITIAL
A derived engine declares an
initial=
attribute. Derived engines compute their initial
state from the
derived=expr
source; an explicit initial is redundant and rejected.
What it means
Per §51.0.J, a derived engine
(<engine for=Type derived=expr>)
takes its state from an upstream reactive expression.
The initial value is whatever
derived=expr
evaluates to at engine-init time. Specifying an
initial=
on top of that is incoherent — it would imply the
engine is BOTH driven by the derived expression AND
seeded by an authored initial. The compiler rejects.
Minimal reproducer
type Phase:enum = { Idle, Loading, Ready }
<ready> = false
<loading> = false
<engine for=Phase derived=computePhase(@ready, @loading) initial=.Idle>
// ^^^^^^^^^^^^
// E-DERIVED-ENGINE-NO-INITIAL
<Idle/>
<Loading/>
<Ready/>
</>
How to fix
Drop the
initial=
attribute. The derived expression provides the initial
value automatically:
<engine for=Phase derived=computePhase(@ready, @loading)>
<Idle/>
<Loading/>
<Ready/>
</>
If the
derived=expr
evaluates to scrml-absence
(not)
when the upstream sources are in their initial state,
you'll get
E-DERIVED-ENGINE-INITIAL-ABSENT
instead — that's the signal to fix the upstream
expression to always produce a defined variant.
Related
- <engine> — the engine element reference; derived form is one of two flavours.
- derived — the wider semantics of derived bindings.
Specification
Normative text:
SPEC §51.0.J
(derived engines, the rules table that rejects
initial=).
Companion errors:
E-DERIVED-ENGINE-NO-RULES
(no
rule=
on state-children) and
E-DERIVED-ENGINE-NO-WRITE
(no direct writes to the engine variable).