bynk.types.function_at_boundary
Error A function type appeared in a serialisable or boundary position (a record field, sum payload, service/agent handler signature, capability operation signature, agent state field, or agent key); functions cannot serialise or cross a boundary.
A function type can be written only where a value stays in the running program: as a fn or lambda parameter, a return, or a local. A value that is serialised, stored or sent has to be data, and a function has no wire form, so a function type in a record field, a sum payload, an event field, a service or agent handler signature, an agent key or store field, a capability operation or an actor identity is refused where it is written. Keep the function out of the type: pass it as a parameter to the fn that needs it, or store the data it is built from, such as a name or a number, and rebuild the behaviour on the other side.
Example
type Job = { name: String, run: Int -> Int, // ✗ a record field cannot hold a function}
type Job = { name: String, step: Int,}
fn run(j: Job, f: Int -> Int) -> Int { // ✓ a parameter can f(j.step)}In the Book
See also
- The grammar rule it governs:
function_type_ref. - Every code in its category, Type checking, on the diagnostic index.
bynk explain bynk.types.function_at_boundaryshows the same from the installed toolchain, without a network.