Files
sdk/pkg/front_end/parser_testcases/patterns/switchExpression_recovery_illegalFunctionExpressionInGuard.dart.parser.expect
Paul Berry c2713ca752 Patterns parsing: improve error recovery for switch expressions.
If the parser gets lost during a switch expression, it now attempts to
pick back up at the next `,` in between the curly braces (ignoring
more deeply nested commas).  This allows much better error recovery in
the case where an illegal function expression appears in a guard.

Fixes #51906.

Bug: https://github.com/dart-lang/sdk/issues/51906
Change-Id: I1cb43857ccc04f0e4146c23c9e07acb02a80d405
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293083
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-04-04 03:29:39 +00:00

12 lines
437 B
Plaintext

f(x) => switch (x) {
_ when () => true => 1,
_ => 2
};
f[StringToken]([BeginToken]x[StringToken])[SimpleToken] =>[SimpleToken] switch[KeywordToken] ([BeginToken]x[StringToken])[SimpleToken] {[BeginToken]
_[StringToken] when[KeywordToken] ([BeginToken])[SimpleToken] =>[SimpleToken] true[KeywordToken] =>[SimpleToken] 1[StringToken],[SimpleToken]
_[StringToken] =>[SimpleToken] 2[StringToken]
}[SimpleToken];[SimpleToken]
[SimpleToken]