Skip to content
Playground(another site)

bynk.cell.self_reference

Error A := right-hand side reads the cell being written (a read-modify-write); use .update.

A := writes a Cell store field, and its right-hand side may not read the cell it is writing. Computing the new value from the old one is a hidden read-modify-write; Bynk asks for .update(fn) instead, so the dependency on the prior value is written down where a reader (and a retry) can see it. A := is for a value that does not depend on what the cell held.

Example

count := count + 1 // ✗ reads `count` while writing it
let _ <- count.update((c) => c + 1) // ✓ awaited, as an effect; the combiner gets the old value

In the Book

See also

  • Every code in its category, Other, on the diagnostic index.
  • bynk explain bynk.cell.self_reference shows the same from the installed toolchain, without a network.