Skip to content

Commit 45753be

Browse files
committed
add a small section about or-pattern precedence and delimiters
1 parent f567a17 commit 45753be

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/patterns.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,15 @@ closure arguments (represented by the _PatternNoTopAlt_ production).
807807
potential factors in `c`, is defined as being the same as that of
808808
`c(p, ..rest) | c(q, ..rest)`.
809809

810+
### Precedence with other undelimited patterns
811+
812+
As shown elsewhere in this chapter, there are several types of patterns that
813+
are syntactically undelimited, including identifier patterns, reference
814+
patterns, and or-patterns. Or-patterns always have the lowest-precedence. This
815+
allows us to reserve syntactic space for a possible future type ascription
816+
feature and also to reduce ambiguity. For example, `x @ A(..) | B(..)` will
817+
result in an error that `x` is not bound in all patterns, `&A(x) | B(x)` will
818+
result in a type mismatch between `x` in the different subpatterns.
810819

811820
[_GroupedPattern_]: #grouped-patterns
812821
[_IdentifierPattern_]: #identifier-patterns

0 commit comments

Comments
 (0)