✓
Passing Passing: the compiler rejects this program as expected.
Code
// STRICT 1:1, the discard side: a pattern that declares named groups but
// discards the payload asked for captures it never takes delivery of.
// The discard form lives in the PATTERN — spell unwanted captures `(...)`.
import std/io
import std/regex
std/regex:match("42")
| `(?<x>[0-9]+)` _ |> std/io:print.ln("num")
| no-match |> std/io:print.ln("no")
Actual compiler output
error[KORU162]: regex match: pattern `(?<x>[0-9]+)` declares named groups but the branch discards the payload — destructure them, bind the payload, or make the unwanted capture non-capturing: spell it (...)
--> tests/regression/600_STDLIB/640_REGEX/640_010_reject_groups_discarded/input.k:7:0Must contain:
spell it (...)Flows
flow ~match click a branch to expand · @labels scroll to their anchor
match (expr: "42")
Test Configuration
MUST_ERROR