Repository navigation
Description
Summary
Add missing coverage for already-implemented pattern forms: one-element tuple pattern syntax, unit tuple pattern, empty array patterns, and transitive reference pattern ergonomics. This is a test issue unless the new fixtures expose a real pattern lowering bug.
Spec
§9.7 says (p) is grouping, (p,) is a one-element tuple pattern, and () matches the empty tuple (docs/with-specification.md:3612-3614). It also says [] matches empty arrays and slice patterns support fixed-size array length matching (docs/with-specification.md:3616-3628). The requirements campaign additionally tracks transitive reference pattern ergonomics for matching nested references (docs/requirements.md:3303).
Current state
Pattern sema has tuple support with arity checking (src/SemaCheck.w:6816-6837), slice support including empty/head/rest/tail binding metadata (src/SemaCheck.w:6839-6862), and struct/other pattern paths. MIR lowering has tuple pattern checks/bindings (src/MirLower.w:5175-5210, src/MirLower.w:5344-5369) and slice fixed-array length checks (src/MirLower.w:5245-5267). The requirements campaign marked the listed requirements as verified but untested (out/req-campaign/g04.tsv:144-150, out/req-campaign/g04.tsv:172).
Implementation plan
- Add focused spec tests for tuple grouping vs one-element tuple and
()matching. - Add empty-array slice-pattern tests for
[0]T. - Add transitive reference pattern tests using the simplest currently supported reference form; if the implementation does not support the exact transitive requirement, split that out as an implementation bug rather than weakening the test.
- Avoid duplicating Positional struct patterns: Point(x, y) (§9.7) #468 positional struct patterns, Refutable parameter patterns / multiple function clauses (§9.7) #472 refutable parameter clauses, and Bug: slice ..rest binding fails MIR lowering (§9.7) #474 slice
..restbinding. This issue can mention them but should not claim their coverage.
Test plan
Add test/spec/spec_ss09_7_pattern_forms_more.w:
match (1,): (x,) => assert(x == 1).match (): () => assert(true).- prove
(x)is grouping by matching ani32with(x). match empty_array: [] => assert(true).
Add test/spec/spec_ss09_7_reference_pattern_transitive.w:
- match a nested reference/tuple shape that should bind through references according to the requirement.
Add compile-error coverage if (x,) against a scalar or [] against a non-empty fixed array currently has a useful diagnostic.
Acceptance criteria
- One-element tuple, unit tuple, grouping, and empty-array pattern rules have direct tests.
- Transitive reference pattern ergonomics have direct tests or a newly filed implementation bug if absent.
- Tests do not mask Positional struct patterns: Point(x, y) (§9.7) #468/Refutable parameter patterns / multiple function clauses (§9.7) #472/Bug: slice ..rest binding fails MIR lowering (§9.7) #474 as done.
with build && with build :fixpoint && with build :testpass.
Dependencies
#468, #472, and #474 for adjacent pattern implementation gaps.
Traceability
From the requirements campaign (docs/requirements.md, spec v7.1). Affected requirement IDs: 9.7.1.23, 9.7.1.24, 9.7.1.29, 9.7.1.51.
Activity
ehartford commentedon Jul 3, 2026
Closing the covered surface: one-element tuple pattern (x,) + grouping pinned by spec_ss09_7_one_element_tuple_pattern (6c59303); empty-array [] by slice_pat_empty; transitive reference by spec_ss09_7_reference_pattern_ergonomics. The ONE remaining sub-form — unit-tuple () pattern — is unimplemented and filed as #631 (not a coverage gap, a feature gap). §9.7.
test: coverage-sweep batch 1 (#495 #496 #521 #518 #529 #492 #499)