cli: canonicalize integer match patterns

Emit decimal AIR patterns without source suffixes, radix spellings or
separators. Validate range before formatting and preserve duplicate-value
detection, including negative zero and 128-bit boundaries.

Add source run/reject regressions for canonical spelling, duplicates and
out-of-range patterns; clarify the existing integer pattern contract.
This commit is contained in:
dev committed 2026-10-07 08:31:27 +03:00
1 parent 1eaf968f4f
commit fc23f1b23a
6 files changed
+51 -2

No files matched your search

+1 -1
View File
@@ -239,7 +239,7 @@ match io.stdin_read(input, mut buf) {
- **Rebinding.** A value that comes back on an edge is rebound by the name in its arm: `closed(v)`, `pending(rx)`, `cancelled(t)`. If that name is a variable (`var`) of the value's type, the value becomes the variable's new value. A receiver kept in `var r` is closed with `match channel.close_receiver(move r) { ok => …, pending(r) => … }` and received from again.
- **`or trap`.** `op(args) or trap` is the expression of the `ok` value, or of `void`. Every other outcome traps (`T0001`). It is the only shorthand.
- **Enums.** A `match` over a value of an enum type has exactly one arm per variant, each written `Enum::Variant(names…)` (`Enum::Variant` without payload). It must be exhaustive (`E7004` lists the missing variants), and `_` is not allowed (`E7006`), so a new variant cannot slip through silently. Payload names are bound only inside their arm (they are the arm block's parameters in AIR). It lowers to `enum.switch`.
- **Integers.** A `match` over an integer has literal arms and exactly one `_` arm, which is required (`E7004`). It lowers to `switch`.
- **Integers.** A `match` over an integer has literal arms and exactly one `_` arm, which is required (`E7004`). Pattern values MUST fit the scrutinee type (`E7005`); different spellings of the same value are duplicate arms (`E7006`). It lowers to `switch` with canonical decimal literals, without source suffixes or separators.
- **Booleans** use `if`.
- **As expressions.** `match` and `if` are expressions when their arms yield values (§4). Every arm must have the type of the others, or diverge.
- **Source map.** The switch maps to the `match`; each arm's code and its branch to the join map to that arm.