Skip to content

Commit 8a9b9a8

Browse files
authored
Explicit binders in cases (#2475)
* [patterns] Tease apart type testing from refutability. Some patterns fail to match if the value doesn't have a certain type. We still allow those patterns in irrefutable contexts if the matched value is statically known to always have that type (or be dynamic). Instead of specifying by having the refutability state of those patterns depend on their type, make refutability a syntactic property and then define the compile-time error for the types during type checking. Fix #2450. * Make variable binders explicit in pattern declarations. This leads to a cascade of other (hopefully for the better) changes: - Treat short identifiers as constants in cases. - Use `if (<expr> case <pat>)` instead of `if (var <pat> = <expr>)`. - Merge literal and constant patterns into a single construct. Extend it to support other constant expressions. There are some other mostly unrelated changes too: - Don't allow unary patterns to nest. - Allow subpatterns in cast patterns. - Only allow assigning to local variables in pattern assignments. * Revise based on review feedback. Also consolidate breaking changes into a single section and explain `_` and other breakage.
1 parent 113dcc4 commit 8a9b9a8

File tree

1 file changed

+559
-396
lines changed

1 file changed

+559
-396
lines changed

0 commit comments

Comments
 (0)