Skip to content
Playground(another site)

bynk.parse.storage_after_phase

Error Agent storage (state / store) is declared after the invariants or handlers.

An agent's body is ordered: its key, its storage fields (state and store), its invariants and migrations, then its handlers. Putting the fields first means the whole shape of the agent's persisted state is read before any code that uses it. A storage field declared after an invariant or a handler is refused. Move it up beside the other fields.

Example

agent Counter {
key id: String
store count: Cell[Int]
on call bump() -> Effect[()] { … }
store extra: Cell[Int] = 0 // ✗ storage after a handler
}
agent Counter {
key id: String
store count: Cell[Int]
store extra: Cell[Int] = 0 // ✓ with the other fields
on call bump() -> Effect[()] { … }
}

In the Book

See also

  • Every code in its category, Parser, on the diagnostic index.
  • bynk explain bynk.parse.storage_after_phase shows the same from the installed toolchain, without a network.