-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for expression statements beginning with a map pattern.
Bug: #50035, dart-lang/language#2662 Change-Id: Ifb141cf563848fc0035423a625e27585cce2ea57 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272523 Commit-Queue: Paul Berry <[email protected]> Reviewed-by: Jens Johansen <[email protected]>
- Loading branch information
1 parent
3e00e6a
commit 701a0d2
Showing
12 changed files
with
343 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...nd/parser_testcases/patterns/map_insideAssignment_untyped_empty_beginningOfStatement.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
void f(x) { | ||
{} = x; | ||
} |
31 changes: 31 additions & 0 deletions
31
...er_testcases/patterns/map_insideAssignment_untyped_empty_beginningOfStatement.dart.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
beginCompilationUnit(void) | ||
beginMetadataStar(void) | ||
endMetadataStar(0) | ||
beginTopLevelMember(void) | ||
beginTopLevelMethod(, null, null) | ||
handleVoidKeyword(void) | ||
handleIdentifier(f, topLevelFunctionDeclaration) | ||
handleNoTypeVariables(() | ||
beginFormalParameters((, MemberKind.TopLevelMethod) | ||
beginMetadataStar(x) | ||
endMetadataStar(0) | ||
beginFormalParameter(x, MemberKind.TopLevelMethod, null, null, null) | ||
handleNoType(() | ||
handleIdentifier(x, formalParameterDeclaration) | ||
handleFormalParameterWithoutValue()) | ||
endFormalParameter(null, null, null, x, null, null, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
endFormalParameters(1, (, ), MemberKind.TopLevelMethod) | ||
handleAsyncModifier(null, null) | ||
beginBlockFunctionBody({) | ||
handleNoTypeArguments({) | ||
handleMapPattern(0, {, }) | ||
handleIdentifier(x, expression) | ||
handleNoTypeArguments(;) | ||
handleNoArguments(;) | ||
handleSend(x, ;) | ||
handlePatternAssignment(=) | ||
handleExpressionStatement(;) | ||
endBlockFunctionBody(1, {, }) | ||
endTopLevelMethod(void, null, }) | ||
endTopLevelDeclaration() | ||
endCompilationUnit(1, ) |
75 changes: 75 additions & 0 deletions
75
.../patterns/map_insideAssignment_untyped_empty_beginningOfStatement.dart.intertwined.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
parseUnit(void) | ||
skipErrorTokens(void) | ||
listener: beginCompilationUnit(void) | ||
syntheticPreviousToken(void) | ||
parseTopLevelDeclarationImpl(, Instance of 'DirectiveContext') | ||
parseMetadataStar() | ||
listener: beginMetadataStar(void) | ||
listener: endMetadataStar(0) | ||
parseTopLevelMemberImpl() | ||
listener: beginTopLevelMember(void) | ||
parseTopLevelMethod(, null, null, , Instance of 'VoidType', null, f, false) | ||
listener: beginTopLevelMethod(, null, null) | ||
listener: handleVoidKeyword(void) | ||
ensureIdentifierPotentiallyRecovered(void, topLevelFunctionDeclaration, false) | ||
listener: handleIdentifier(f, topLevelFunctionDeclaration) | ||
parseMethodTypeVar(f) | ||
listener: handleNoTypeVariables(() | ||
parseGetterOrFormalParameters(f, f, false, MemberKind.TopLevelMethod) | ||
parseFormalParameters(f, MemberKind.TopLevelMethod) | ||
parseFormalParametersRest((, MemberKind.TopLevelMethod) | ||
listener: beginFormalParameters((, MemberKind.TopLevelMethod) | ||
parseFormalParameter((, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
parseMetadataStar(() | ||
listener: beginMetadataStar(x) | ||
listener: endMetadataStar(0) | ||
listener: beginFormalParameter(x, MemberKind.TopLevelMethod, null, null, null) | ||
listener: handleNoType(() | ||
ensureIdentifier((, formalParameterDeclaration) | ||
listener: handleIdentifier(x, formalParameterDeclaration) | ||
listener: handleFormalParameterWithoutValue()) | ||
listener: endFormalParameter(null, null, null, x, null, null, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
listener: endFormalParameters(1, (, ), MemberKind.TopLevelMethod) | ||
parseAsyncModifierOpt()) | ||
listener: handleAsyncModifier(null, null) | ||
inPlainSync() | ||
parseFunctionBody(), false, false) | ||
listener: beginBlockFunctionBody({) | ||
notEofOrValue(}, {) | ||
parseStatement({) | ||
parseStatementX({) | ||
parseExpressionStatement({) | ||
parseExpression({) | ||
looksLikeOuterPatternEquals({) | ||
skipOuterPattern({) | ||
parsePatternAssignment({) | ||
parsePattern({, precedence: 1, isRefutableContext: false) | ||
parsePrimaryPattern({, isRefutableContext: false) | ||
listener: handleNoTypeArguments({) | ||
parseMapPatternSuffix({, isRefutableContext: false) | ||
listener: handleMapPattern(0, {, }) | ||
parseExpression(=) | ||
looksLikeOuterPatternEquals(=) | ||
skipOuterPattern(=) | ||
skipObjectPatternRest(x) | ||
parsePrecedenceExpression(=, 1, true) | ||
parseUnaryExpression(=, true) | ||
parsePrimary(=, expression) | ||
parseSendOrFunctionLiteral(=, expression) | ||
parseSend(=, expression) | ||
isNextIdentifier(=) | ||
ensureIdentifier(=, expression) | ||
listener: handleIdentifier(x, expression) | ||
listener: handleNoTypeArguments(;) | ||
parseArgumentsOpt(x) | ||
listener: handleNoArguments(;) | ||
listener: handleSend(x, ;) | ||
listener: handlePatternAssignment(=) | ||
ensureSemicolon(x) | ||
listener: handleExpressionStatement(;) | ||
notEofOrValue(}, }) | ||
listener: endBlockFunctionBody(1, {, }) | ||
listener: endTopLevelMethod(void, null, }) | ||
listener: endTopLevelDeclaration() | ||
reportAllErrorTokens(void) | ||
listener: endCompilationUnit(1, ) |
9 changes: 9 additions & 0 deletions
9
...cases/patterns/map_insideAssignment_untyped_empty_beginningOfStatement.dart.parser.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
void f(x) { | ||
{} = x; | ||
} | ||
|
||
|
||
void[KeywordToken] f[StringToken]([BeginToken]x[StringToken])[SimpleToken] {[BeginToken] | ||
{[BeginToken]}[SimpleToken] =[SimpleToken] x[StringToken];[SimpleToken] | ||
}[SimpleToken] | ||
[SimpleToken] |
9 changes: 9 additions & 0 deletions
9
...ases/patterns/map_insideAssignment_untyped_empty_beginningOfStatement.dart.scanner.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
void f(x) { | ||
{} = x; | ||
} | ||
|
||
|
||
void[KeywordToken] f[StringToken]([BeginToken]x[StringToken])[SimpleToken] {[BeginToken] | ||
{[BeginToken]}[SimpleToken] =[SimpleToken] x[StringToken];[SimpleToken] | ||
}[SimpleToken] | ||
[SimpleToken] |
3 changes: 3 additions & 0 deletions
3
...parser_testcases/patterns/map_insideAssignment_untyped_nonEmpty_beginningOfStatement.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
void f(x) { | ||
{'a': a, 'b': b} = x; | ||
} |
41 changes: 41 additions & 0 deletions
41
...testcases/patterns/map_insideAssignment_untyped_nonEmpty_beginningOfStatement.dart.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
beginCompilationUnit(void) | ||
beginMetadataStar(void) | ||
endMetadataStar(0) | ||
beginTopLevelMember(void) | ||
beginTopLevelMethod(, null, null) | ||
handleVoidKeyword(void) | ||
handleIdentifier(f, topLevelFunctionDeclaration) | ||
handleNoTypeVariables(() | ||
beginFormalParameters((, MemberKind.TopLevelMethod) | ||
beginMetadataStar(x) | ||
endMetadataStar(0) | ||
beginFormalParameter(x, MemberKind.TopLevelMethod, null, null, null) | ||
handleNoType(() | ||
handleIdentifier(x, formalParameterDeclaration) | ||
handleFormalParameterWithoutValue()) | ||
endFormalParameter(null, null, null, x, null, null, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
endFormalParameters(1, (, ), MemberKind.TopLevelMethod) | ||
handleAsyncModifier(null, null) | ||
beginBlockFunctionBody({) | ||
handleNoTypeArguments({) | ||
beginLiteralString('a') | ||
endLiteralString(0, :) | ||
handleNoType(:) | ||
handleVariablePattern(null, a) | ||
handleMapPatternEntry(:, ,) | ||
beginLiteralString('b') | ||
endLiteralString(0, :) | ||
handleNoType(:) | ||
handleVariablePattern(null, b) | ||
handleMapPatternEntry(:, }) | ||
handleMapPattern(2, {, }) | ||
handleIdentifier(x, expression) | ||
handleNoTypeArguments(;) | ||
handleNoArguments(;) | ||
handleSend(x, ;) | ||
handlePatternAssignment(=) | ||
handleExpressionStatement(;) | ||
endBlockFunctionBody(1, {, }) | ||
endTopLevelMethod(void, null, }) | ||
endTopLevelDeclaration() | ||
endCompilationUnit(1, ) |
107 changes: 107 additions & 0 deletions
107
...tterns/map_insideAssignment_untyped_nonEmpty_beginningOfStatement.dart.intertwined.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
parseUnit(void) | ||
skipErrorTokens(void) | ||
listener: beginCompilationUnit(void) | ||
syntheticPreviousToken(void) | ||
parseTopLevelDeclarationImpl(, Instance of 'DirectiveContext') | ||
parseMetadataStar() | ||
listener: beginMetadataStar(void) | ||
listener: endMetadataStar(0) | ||
parseTopLevelMemberImpl() | ||
listener: beginTopLevelMember(void) | ||
parseTopLevelMethod(, null, null, , Instance of 'VoidType', null, f, false) | ||
listener: beginTopLevelMethod(, null, null) | ||
listener: handleVoidKeyword(void) | ||
ensureIdentifierPotentiallyRecovered(void, topLevelFunctionDeclaration, false) | ||
listener: handleIdentifier(f, topLevelFunctionDeclaration) | ||
parseMethodTypeVar(f) | ||
listener: handleNoTypeVariables(() | ||
parseGetterOrFormalParameters(f, f, false, MemberKind.TopLevelMethod) | ||
parseFormalParameters(f, MemberKind.TopLevelMethod) | ||
parseFormalParametersRest((, MemberKind.TopLevelMethod) | ||
listener: beginFormalParameters((, MemberKind.TopLevelMethod) | ||
parseFormalParameter((, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
parseMetadataStar(() | ||
listener: beginMetadataStar(x) | ||
listener: endMetadataStar(0) | ||
listener: beginFormalParameter(x, MemberKind.TopLevelMethod, null, null, null) | ||
listener: handleNoType(() | ||
ensureIdentifier((, formalParameterDeclaration) | ||
listener: handleIdentifier(x, formalParameterDeclaration) | ||
listener: handleFormalParameterWithoutValue()) | ||
listener: endFormalParameter(null, null, null, x, null, null, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod) | ||
listener: endFormalParameters(1, (, ), MemberKind.TopLevelMethod) | ||
parseAsyncModifierOpt()) | ||
listener: handleAsyncModifier(null, null) | ||
inPlainSync() | ||
parseFunctionBody(), false, false) | ||
listener: beginBlockFunctionBody({) | ||
notEofOrValue(}, {) | ||
parseStatement({) | ||
parseStatementX({) | ||
parseExpressionStatement({) | ||
parseExpression({) | ||
looksLikeOuterPatternEquals({) | ||
skipOuterPattern({) | ||
parsePatternAssignment({) | ||
parsePattern({, precedence: 1, isRefutableContext: false) | ||
parsePrimaryPattern({, isRefutableContext: false) | ||
listener: handleNoTypeArguments({) | ||
parseMapPatternSuffix({, isRefutableContext: false) | ||
parseExpression({) | ||
looksLikeOuterPatternEquals({) | ||
skipOuterPattern({) | ||
parsePrecedenceExpression({, 1, true) | ||
parseUnaryExpression({, true) | ||
parsePrimary({, expression) | ||
parseLiteralString({) | ||
parseSingleLiteralString({) | ||
listener: beginLiteralString('a') | ||
listener: endLiteralString(0, :) | ||
parsePattern(:, precedence: 1, isRefutableContext: false) | ||
parsePrimaryPattern(:, isRefutableContext: false) | ||
parseVariablePattern(:, typeInfo: Instance of 'NoType') | ||
listener: handleNoType(:) | ||
listener: handleVariablePattern(null, a) | ||
listener: handleMapPatternEntry(:, ,) | ||
parseExpression(,) | ||
looksLikeOuterPatternEquals(,) | ||
skipOuterPattern(,) | ||
parsePrecedenceExpression(,, 1, true) | ||
parseUnaryExpression(,, true) | ||
parsePrimary(,, expression) | ||
parseLiteralString(,) | ||
parseSingleLiteralString(,) | ||
listener: beginLiteralString('b') | ||
listener: endLiteralString(0, :) | ||
parsePattern(:, precedence: 1, isRefutableContext: false) | ||
parsePrimaryPattern(:, isRefutableContext: false) | ||
parseVariablePattern(:, typeInfo: Instance of 'NoType') | ||
listener: handleNoType(:) | ||
listener: handleVariablePattern(null, b) | ||
listener: handleMapPatternEntry(:, }) | ||
listener: handleMapPattern(2, {, }) | ||
parseExpression(=) | ||
looksLikeOuterPatternEquals(=) | ||
skipOuterPattern(=) | ||
skipObjectPatternRest(x) | ||
parsePrecedenceExpression(=, 1, true) | ||
parseUnaryExpression(=, true) | ||
parsePrimary(=, expression) | ||
parseSendOrFunctionLiteral(=, expression) | ||
parseSend(=, expression) | ||
isNextIdentifier(=) | ||
ensureIdentifier(=, expression) | ||
listener: handleIdentifier(x, expression) | ||
listener: handleNoTypeArguments(;) | ||
parseArgumentsOpt(x) | ||
listener: handleNoArguments(;) | ||
listener: handleSend(x, ;) | ||
listener: handlePatternAssignment(=) | ||
ensureSemicolon(x) | ||
listener: handleExpressionStatement(;) | ||
notEofOrValue(}, }) | ||
listener: endBlockFunctionBody(1, {, }) | ||
listener: endTopLevelMethod(void, null, }) | ||
listener: endTopLevelDeclaration() | ||
reportAllErrorTokens(void) | ||
listener: endCompilationUnit(1, ) |
9 changes: 9 additions & 0 deletions
9
...es/patterns/map_insideAssignment_untyped_nonEmpty_beginningOfStatement.dart.parser.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
void f(x) { | ||
{'a': a, 'b': b} = x; | ||
} | ||
|
||
|
||
void[KeywordToken] f[StringToken]([BeginToken]x[StringToken])[SimpleToken] {[BeginToken] | ||
{[BeginToken]'a'[StringToken]:[SimpleToken] a[StringToken],[SimpleToken] 'b'[StringToken]:[SimpleToken] b[StringToken]}[SimpleToken] =[SimpleToken] x[StringToken];[SimpleToken] | ||
}[SimpleToken] | ||
[SimpleToken] |
9 changes: 9 additions & 0 deletions
9
...s/patterns/map_insideAssignment_untyped_nonEmpty_beginningOfStatement.dart.scanner.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
void f(x) { | ||
{'a': a, 'b': b} = x; | ||
} | ||
|
||
|
||
void[KeywordToken] f[StringToken]([BeginToken]x[StringToken])[SimpleToken] {[BeginToken] | ||
{[BeginToken]'a'[StringToken]:[SimpleToken] a[StringToken],[SimpleToken] 'b'[StringToken]:[SimpleToken] b[StringToken]}[SimpleToken] =[SimpleToken] x[StringToken];[SimpleToken] | ||
}[SimpleToken] | ||
[SimpleToken] |