90. Partial-injection a.inverse() on [D]?E -> [E]?D (2026-11-21)
- Decision: Type and lower
a.inverse()uniformly on 1D arrays incpl-checkandcpl-ir: a partial injectiona: [D]?E(whereEis an index domain, fieldless enum, or bounded integer range) returns[E]?Dand traps on duplicate images (Stmt::Trapin both interpreter and C++); a total bijectiona: [D]Ekeeps returning[E]Dand traps on duplicate or missing images. Arrays with non-index elements (e.g.[D]?Int) are rejected at check time withE0302. - Reason: Partial permutations with holes (
a: [P]?(1..=n) = read(none: 0)incf2084g1anda: [Pos]?(0..Pos.count) = read(none: -1)incf2084e) previously forced hand-written inversion loops becausestd.seq.inverseonly accepted total bijections[I]V. Typing.inverse()by the input preserves one spelling across total and partial maps and works without extra imports. - Reverse: Remove
array_inverse_retincrates/cpl-check/src/check/expr.rs, theinversearm incrates/cpl-check/src/check/call.rs, andlower_array_inverse+local_specs/global_specsincrates/cpl-ir/src/lower/{mod,stmt,call}.rs.