e7c6654312
Permit `abstract` on top-level variable declarations when the augmentations feature is enabled. Previously the parser always reported `abstract` as extraneous at the top level, which rejected valid syntax and dropped the modifier before later stages could see it. Thread the abstract token through top-level field parsing, record it on `TopLevelVariableDeclaration`, and pass it through the front-end builders. Reorder the field callback arguments so `augment` precedes `abstract`, matching the augmentation grammar for incomplete top-level variables and keeping the parser, listener, and outline plumbing consistent. Change-Id: I680414a746b707d483e485702685c95f28a9c9ac Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494564 Reviewed-by: Samuel Rawlins <srawlins@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
26 lines
955 B
Plaintext
26 lines
955 B
Plaintext
Problems reported:
|
|
|
|
parser/patterns/patternVariableDeclaration_topLevel:1:5: A pattern variable declaration may not appear outside a function or method.
|
|
var (a, b) = (0, 1);
|
|
^^^^^^
|
|
|
|
beginCompilationUnit(var)
|
|
beginMetadataStar(var)
|
|
endMetadataStar(0)
|
|
beginTopLevelMember(var)
|
|
handleRecoverableError(PatternVariableDeclarationOutsideFunctionOrMethod, (, ))
|
|
beginFields(DeclarationKind.TopLevel, null, null, null, null, null, null, var, )
|
|
handleNoType(var)
|
|
handleIdentifier(, topLevelVariableDeclaration)
|
|
beginFieldInitializer(=)
|
|
beginParenthesizedExpressionOrRecordLiteral(()
|
|
handleLiteralInt(0)
|
|
handlePositionalRecordField(0)
|
|
handleLiteralInt(1)
|
|
handlePositionalRecordField(1)
|
|
endRecordLiteral((, 2, null)
|
|
endFieldInitializer(=, ))
|
|
endTopLevelFields(null, null, null, null, null, null, var, 1, var, ;)
|
|
endTopLevelDeclaration(;)
|
|
endCompilationUnit(1, )
|