bynk.detach.in_pure_context
Error A detach was used in a pure (non-effectful) context.
detach hands a running effect to the execution context, and only an effectful body has effects to run: a pure function never runs one. Change the enclosing function's return type to Effect[…]. The same rule holds for bynk.within.in_pure_context and bynk.race.in_pure_context.
Example
fn twice(ping: Effect[()], n: Int) -> Int { let _ = ping.detach() // ✗ the body is pure n * 2}
fn twice(ping: Effect[()], n: Int) -> Effect[Int] { // ✓ an effectful body do ping.detach() Effect.pure(n * 2)}In the Book
See also
- The grammar rule it governs:
method_call. - Every code in its category, Other, on the diagnostic index.
bynk explain bynk.detach.in_pure_contextshows the same from the installed toolchain, without a network.