✓
Passing Passing: the compiler rejects this program as expected.
Code
// std/channel — `recv` can't spell one payload type on a multi-kind
// channel; consumers arm per kind. The refusal points at the `!` join.
import std/io
import std/proto
import std/channel
std/proto(Reading) {
id: u64
}
std/proto(Alert) {
level: u64
}
std/channel:new(wire, capacity: 8) { reading: Reading, alert: Alert }
std/channel:recv(wire)
| some v |> std/io:print.ln("{{ v:s }}")
| none |> std/io:print.ln("none")
| closed |> std/io:print.ln("closed")
Actual compiler output
error[KORU161]: std/channel:recv(wire): recv can't spell one payload type on a multi-kind channel — consume by `!` arms: `std/channel(wire) ! reading v |> ...`
--> tests/regression/600_STDLIB/699_CHANNEL/699_014_recv_multi_kind_refused/input.k:17:0Compiler must reject:
Compilation must fail with a diagnostic.
Flows
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Reading, source: id: u64)
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Alert, source: level: u64)
flow ~new click a branch to expand · @labels scroll to their anchor
new (expr: wire, capacity: 8, source: reading: Reading, alert: Alert)
flow ~recv click a branch to expand · @labels scroll to their anchor
recv (expr: wire)
Test Configuration
MUST_ERROR