S0147: array pattern does not match scrutinee
Generated from rellum-diagnostics/src/db.rs.
Explanation
Array patterns can only destructure array values. They perform an exact runtime length check before binding element sub-patterns.
Common causes
- using
[a, b]against a non-array value - expecting an array pattern to match any length rather than exactly its listed element count
Canonical fixes
- match an array value
Before:
match text { [a, b] => a }
After:
match chars(text) { [a, b] => a }
- add a fallback arm because array patterns are refutable
Before:
match values { [a, b] => a + b }
After:
match values { [a, b] => a + b _ => 0 }
Code example
match text { [a, b] => a }