1 Commits

Author SHA1 Message Date
Paul Berry 8aa48712be Patterns parsing: recover from patternVariableDeclaration non-statement.
Previously, if a pattern variable declaration appeared outside of a
function or method, the parser would get very confused.  Now it
recognizes the situation, issues a comprehensible error message, and
replaces the pattern with a synthetic identifier token so that the
analyzer AST is somewhat sensible.

Fixes #51322.

Bug: https://github.com/dart-lang/sdk/issues/51322
Change-Id: Ica5f060cb483a39c4e50942d639939b1fab40bea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293087
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-04-04 14:55:00 +00:00