Skip to content
Playground(another site)

bynk.agent.state_name_conflict

Error A type is named <Agent>State beside agent <Agent>; that name is the agent's state record (its Cell fields), which its handlers and invariants see in place of the type.

Inside an agent's handlers and invariants, <Agent>State names the record of the agent's Cell fields: for agent Counter, CounterState. A type you declare with that name would be silently replaced there, so the compiler refuses it instead of renaming anything: unlike the names it derives elsewhere, this one can be written in a program. Rename your type.

Example

type CounterState = { label: String } // ✗ the name of `Counter`'s state record
type CounterLabel = { label: String } // ✓ any other name
agent Counter {
key id: String
store n: Cell[Int]
on call add(k: Int) -> Effect[Int] { k }
}

In the Book

See also

  • Every code in its category, Agents, on the diagnostic index.
  • bynk explain bynk.agent.state_name_conflict shows the same from the installed toolchain, without a network.