scrml.dev v0.7.1
Reference › Errors

E-DERIVED-WRITE

Assignment to a derived reactive value.

Error Compile-time SPEC §6.6.8 (normative)

What it means

A derived cell (const <name> = expr) is defined entirely by its expression. Its value is recomputed whenever a dependency changes, so any value you assign to it directly would be discarded at the next recomputation. Rather than let that silently happen, the compiler rejects the write. The same code also fires for default= on a derived cell, which is the declaration-time form of the same mistake.

Minimal reproducer

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

<program title="p">
    <count> = 1
    const <double> = @count * 2
    function bump() { @double = 9 }
    <button onclick=bump()>go</button>
</>

How to fix

  1. Write the source cell instead. Assign to whichever plain cell the derived expression reads. The derived value updates on its own — that is the entire point of declaring it derived.
  2. Make it a plain cell if it genuinely needs writing. If a value is sometimes computed and sometimes set by hand, it is not derived. Declare it as <name> = init and compute it explicitly.

Related

Specification

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

← Reference