Skip to content

Commit b3836fc

Browse files
authored
[patterns] Fix spec for context type schema of variable and identifiers. (#2796)
This got slightly broken when I moved identifiers out to a separate pattern grammar. This PR puts it back to right. Fix #2795.
1 parent 2cbd036 commit b3836fc

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

accepted/future-releases/0546-patterns/feature-specification.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,25 +1771,25 @@ The context type schema for a pattern `p` is:
17711771
17721772
* **Variable**:
17731773
1774-
1. In an assignment context, the context type schema is the static type of
1775-
the variable that `p` resolves to.
1776-
1777-
1. Else if `p` has no type annotation, the context type schema is `_`.
1778-
*This lets us potentially infer the variable's type from the matched
1779-
value.*
1780-
1781-
2. Else the context type schema is the annotated type. *When a typed
1782-
variable pattern is used in a destructuring variable declaration, we
1783-
do push the type over to the value for inference, as in:*
1774+
1. If `p` has a type annotation, the context type schema is the annotated
1775+
type. *When a typed variable pattern is used in a destructuring variable
1776+
declaration, we push the type over to the value for inference, as in:*
17841777
17851778
```dart
17861779
var (items: List<int> x) = (items: []);
17871780
// ^- Infers List<int>.
17881781
```
17891782
1790-
* **Identifier**: Context type schemas are only used in irrefutable contexts,
1791-
so an identifier pattern is always a variable and is handled like a
1792-
variable pattern, as above.
1783+
2. Else the context type schema is `_`. *This lets us potentially infer the
1784+
variable's type from the matched value.*
1785+
1786+
* **Identifier**:
1787+
1788+
1. In an assignment context, the context type schema is the static type of
1789+
the variable that `p` resolves to.
1790+
1791+
2. Else the context type schema is `_`. *This lets us potentially infer the
1792+
variable's type from the matched value.*
17931793
17941794
* **Cast**: The context type schema is `_`.
17951795

0 commit comments

Comments
 (0)