d2184a9d03
The precedence-based pattern parser can understand a unary pattern inside another unary pattern (e.g. `_ as int as num`) or a relational pattern inside a unary pattern (e.g. `> 1?`), but the specification prohibits these constructions because they're difficult to read and not very useful. This change updates the implementation to match the spec, by producing the appropriate error. The offset and length of the error cover the inner pattern, so it should be easy to construct an analysis server quick fix that inserts the necessary parentheses. Bug: https://github.com/dart-lang/sdk/issues/50035 Change-Id: I33e74d6d1f863e7162851d26fefbacd4fd17277c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292120 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
8 lines
83 B
Dart
8 lines
83 B
Dart
void f(x) {
|
|
const y = 1;
|
|
switch (x) {
|
|
case y as int? ?:
|
|
break;
|
|
}
|
|
}
|