You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add `MatchPattern::List` and lower it on both backends at parity: `[]`,
fixed-length `[a, b]`, head/rest `[first, ..rest]`, tail `[..init, last]`,
and middle-rest `[a, ..mid, z]`.
- Parser: `parse_list_pattern` (and `..`/`..name` rest segment parsing) wired
into `parse_match_pattern` ahead of paren/tuple grouping.
- Checker: scrutinee type `List<T>` accepted; element patterns checked against
`T`; structured-pattern scrutinee-effect requirement extended to lists;
exhaustiveness tracks covered lengths so `[]` + `[x, ..rest]` is exhaustive.
- reg VM: length test (`>=`/`<=` bracketing, no `Equal` opcode) plus `ListGet`
for fixed elements and `List.slice` for the bound rest.
- rust_lower: native Rust slice patterns with the scrutinee viewed via
`.as_slice()`; owned rebindings (`*x` / `x.clone()` / `rest.to_vec()`) so
arms see owned `T` / `List<T>` rather than slice references.
- Formatter round-trips list patterns; symbol index records rest bindings.
Tests: `parity_list_match` VM/compiled parity, `fixtures/pass/list_patterns.rss`,
and a formatter rendering test. Full `cargo test -p rsscript` green; clippy clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
format!("match scrutinee has type `{type_name}`, expected `Option<T>`, `Result<T, E>`, a declared sum/struct/class type, or an `Int`/`String`/`Bool` literal match."),
1901
+
format!("match scrutinee has type `{type_name}`, expected `Option<T>`, `Result<T, E>`, `List<T>`, a declared sum/struct/class type, or an `Int`/`String`/`Bool` literal match."),
0 commit comments