Skip to content
Playground(another site)

bynk.generics.codable_op_return_not_first_party

Error A user-declared capability operation's Codable type parameter appears in its return type. A typed read, the call site decoding the provider's reply as the instantiated payload, is accepted only for the standard library's own operations (#3458, lifting ADR 0696 decision 5).

A Codable parameter of a capability operation is encoded at the call site, so the provider receives plain JSON. Putting T in the return type asks the call site to decode the provider's reply back into T, and that is accepted only for the standard library's own operations, whose providers are reviewed with the runtime and which declare what a reply that does not decode means. A capability you declare returns plain data, such as a String, and you decode it where the call is made with Json.decode.

Example

capability Store {
fn load[T: Codable](id: String) -> Effect[Option[T]] // ✗ `T` in the return type
}
capability Store {
fn load(id: String) -> Effect[Option[String]] // ✓ plain data back
}

In the Book

See also

  • The grammar rule it governs: capability_op.
  • Every code in its category, Generics, on the diagnostic index.
  • bynk explain bynk.generics.codable_op_return_not_first_party shows the same from the installed toolchain, without a network.