Skip to content
Playground(another site)

bynk.agent.key_mismatch

Error An agent key argument has the wrong type.

The key is what picks an instance, so its type is fixed by the agent: the type of its key field. An agent keyed by String cannot be addressed by an Int, because 1 and "1" would otherwise be easy to confuse and could name different instances. Pass a value of the key's type. The number of key arguments is bynk.agent.construction_arity.

Example

agent Counter {
key id: String
store n: Cell[Int]
on call get() -> Effect[Int] {
n
}
}
let v <- Counter(1).get() // ✗ the key is a `String`
let v <- Counter("a").get() // ✓

In the Book

See also

  • The grammar rule it governs: agent_decl.
  • Every code in its category, Agents, on the diagnostic index.
  • bynk explain bynk.agent.key_mismatch shows the same from the installed toolchain, without a network.