Files
sdk/pkg/front_end/parser_testcases/patterns/patternVariableDeclaration_topLevel.dart.intertwined.expect
T
Konstantin Shcheglov e7c6654312 Augment. Allow abstract top-level variables.
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>
2026-04-14 16:12:24 -07:00

57 lines
3.2 KiB
Plaintext

parseUnit(var)
skipErrorTokens(var)
listener: beginCompilationUnit(var)
syntheticPreviousToken(var)
parseTopLevelDeclarationImpl(, DirectiveContext(DirectiveState.Unknown))
parseMetadataStar()
listener: beginMetadataStar(var)
listener: endMetadataStar(0)
parseTopLevelMemberImpl()
listener: beginTopLevelMember(var)
skipOuterPattern(var)
reportRecoverableErrorWithEnd((, ), PatternVariableDeclarationOutsideFunctionOrMethod)
listener: handleRecoverableError(PatternVariableDeclarationOutsideFunctionOrMethod, (, ))
rewriter()
rewriter()
parseFields(, null, null, null, null, null, null, var, var, NoType(), , DeclarationKind.TopLevel, null, true)
listener: beginFields(DeclarationKind.TopLevel, null, null, null, null, null, null, var, )
listener: handleNoType(var)
ensureIdentifierPotentiallyRecovered(var, topLevelVariableDeclaration, true)
listener: handleIdentifier(, topLevelVariableDeclaration)
parseFieldInitializerOpt(, , null, null, null, null, var, DeclarationKind.TopLevel, null)
listener: beginFieldInitializer(=)
parseExpression(=)
looksLikeOuterPatternEquals(=)
skipOuterPattern(=)
parsePrecedenceExpression(=, 1, true, ConstantPatternContext.none)
parseUnaryExpression(=, true, ConstantPatternContext.none)
parsePrimary(=, expression, ConstantPatternContext.none)
parseParenthesizedExpressionFunctionLiteralOrRecordLiteral(=, ConstantPatternContext.none)
parseParenthesizedExpressionOrRecordLiteral(=, null, ConstantPatternContext.none)
listener: beginParenthesizedExpressionOrRecordLiteral(()
parseExpression(()
looksLikeOuterPatternEquals(()
skipOuterPattern(()
parsePrecedenceExpression((, 1, true, ConstantPatternContext.none)
parseUnaryExpression((, true, ConstantPatternContext.none)
parsePrimary((, expression, ConstantPatternContext.none)
parseLiteralInt(()
listener: handleLiteralInt(0)
listener: handlePositionalRecordField(0)
parseExpression(,)
looksLikeOuterPatternEquals(,)
skipOuterPattern(,)
parsePrecedenceExpression(,, 1, true, ConstantPatternContext.none)
parseUnaryExpression(,, true, ConstantPatternContext.none)
parsePrimary(,, expression, ConstantPatternContext.none)
parseLiteralInt(,)
listener: handleLiteralInt(1)
listener: handlePositionalRecordField(1)
ensureCloseParen(1, ()
listener: endRecordLiteral((, 2, null)
listener: endFieldInitializer(=, ))
listener: endTopLevelFields(null, null, null, null, null, null, var, 1, var, ;)
listener: endTopLevelDeclaration(;)
reportAllErrorTokens(var)
listener: endCompilationUnit(1, )