scrml.dev v0.7.1
Reference › Errors

E-DERIVED-VALUE-MUTATE

In-place mutation of a derived cell.

Error Compile-time SPEC §6.5.1 (normative)

What it means

This is the mutation counterpart to E-DERIVED-WRITE. Rebinding a derived cell with = is caught as a write; reaching into it and mutating the value it currently holds — .push(), .sort(), an indexed assignment — is caught here. Both are the same underlying error: the next recomputation rebuilds the value from the expression and the mutation vanishes.

Minimal reproducer

This is the exact source compiled against the linked compiler and verified to produce E-DERIVED-VALUE-MUTATE.

<program title="p">
    <items> = [1, 2]
    const <doubled> = @items
    function bump() { @doubled.push(3) }
    <button onclick=bump()>go</button>
</>

How to fix

  1. Mutate the source collection. Push to the plain cell the derived expression reads from; the derived value recomputes.
  2. Derive a new value rather than editing in place. A derived cell that needs sorting or filtering should express that in its own expression — const <sorted> = @items.toSorted(…) — not mutate an upstream result.

Related

Specification

Normative text: §6.5.1, §6.6.8, §6.6.18, §34. Spec lives at compiler/SPEC.md .

← Reference