Files
sdk/pkg/front_end/parser_testcases/patterns/patternVariableDeclaration_inClass.dart.scanner.expect
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

10 lines
302 B
Plaintext

class C {
var (a, b) = (0, 1);
}
class[KeywordToken] C[StringToken] {[BeginToken]
var[KeywordToken] ([BeginToken]a[StringToken],[SimpleToken] b[StringToken])[SimpleToken] =[SimpleToken] ([BeginToken]0[StringToken],[SimpleToken] 1[StringToken])[SimpleToken];[SimpleToken]
}[SimpleToken]
[SimpleToken]