bynk.agents.bad_state_initialiser
Error An agent store field initialiser is not a static value of the field's type.
A key's state is initialised automatically the first time it is used, before any handler runs, so a store field's = value must be fixed when the program compiles: a literal, a variant, Some/None/Ok/Err, a record, or T.unsafe(lit) for an opaque type. It cannot read self, a parameter or a capability, or call anything. The code is also reported for a static value of the wrong type. Write the starting value out, and set the real one from a handler. A field with no initialiser and no zero is bynk.agents.non_zeroable_state_field.
Example
store label: Cell[String] = self.id // ✗ `self` is not available to an initialiser
store label: Cell[String] = "" // ✓ a static starting valueIn the Book
- Agents › State initialisation
- Agents
- Model an agent as a state machine
- Build a stateful agent and keep its state zeroable
- The agent model
See also
- The grammar rule it governs:
store_field. - Every code in its category, Agents, on the diagnostic index.
bynk explain bynk.agents.bad_state_initialisershows the same from the installed toolchain, without a network.