Skip to content

Commit c800b8d

Browse files
jensjohacommit-bot@chromium.org
authored andcommitted
[parser] Parser tests reproducing bad recovery of 'Stream<List<>>'
Reproduction of issue #42229. Change-Id: I0c70f04663e37d4ed35a70501024cd3cead8c849 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150520 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent b3caf5b commit c800b8d

21 files changed

+420
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stream<List<>>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Problems reported:
2+
3+
parser/error_recovery/issue_42229.crash:1:8: Expected '>' after this.
4+
Stream<List<>>
5+
^^^^
6+
7+
parser/error_recovery/issue_42229.crash:1:1: A function declaration needs an explicit list of parameters.
8+
Stream<List<>>
9+
^^^^^^
10+
11+
parser/error_recovery/issue_42229.crash:1:15: Expected a function body, but got ''.
12+
Stream<List<>>
13+
^...
14+
15+
beginCompilationUnit(Stream)
16+
beginMetadataStar(Stream)
17+
endMetadataStar(0)
18+
beginTopLevelMember(Stream)
19+
beginTopLevelMethod(, null)
20+
handleNoType()
21+
handleIdentifier(Stream, topLevelFunctionDeclaration)
22+
beginTypeVariables(<)
23+
beginMetadataStar(List)
24+
endMetadataStar(0)
25+
handleIdentifier(List, typeVariableDeclaration)
26+
beginTypeVariable(List)
27+
handleTypeVariablesDefined(List, 1)
28+
handleNoType(List)
29+
endTypeVariable(<, 0, null, null)
30+
handleRecoverableError(Message[ExpectedAfterButGot, Expected '>' after this., null, {string: >}], List, List)
31+
endTypeVariables(<, )
32+
handleRecoverableError(MissingFunctionParameters, Stream, Stream)
33+
beginFormalParameters((, MemberKind.TopLevelMethod)
34+
endFormalParameters(0, (, ), MemberKind.TopLevelMethod)
35+
handleAsyncModifier(null, null)
36+
handleRecoverableError(Message[ExpectedFunctionBody, Expected a function body, but got ''., null, {token: }], , )
37+
handleInvalidFunctionBody({)
38+
endTopLevelMethod(Stream, null, })
39+
endTopLevelDeclaration()
40+
endCompilationUnit(1, )
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
parseUnit(Stream)
2+
skipErrorTokens(Stream)
3+
listener: beginCompilationUnit(Stream)
4+
syntheticPreviousToken(Stream)
5+
parseTopLevelDeclarationImpl(, Instance of 'DirectiveContext')
6+
parseMetadataStar()
7+
listener: beginMetadataStar(Stream)
8+
listener: endMetadataStar(0)
9+
parseTopLevelMemberImpl()
10+
listener: beginTopLevelMember(Stream)
11+
isReservedKeyword(<)
12+
parseTopLevelMethod(, null, , Instance of 'NoType', null, Stream, false)
13+
listener: beginTopLevelMethod(, null)
14+
listener: handleNoType()
15+
ensureIdentifierPotentiallyRecovered(, topLevelFunctionDeclaration, false)
16+
listener: handleIdentifier(Stream, topLevelFunctionDeclaration)
17+
parseMethodTypeVar(Stream)
18+
listener: beginTypeVariables(<)
19+
parseMetadataStar(<)
20+
listener: beginMetadataStar(List)
21+
listener: endMetadataStar(0)
22+
ensureIdentifier(<, typeVariableDeclaration)
23+
listener: handleIdentifier(List, typeVariableDeclaration)
24+
listener: beginTypeVariable(List)
25+
listener: handleTypeVariablesDefined(List, 1)
26+
listener: handleNoType(List)
27+
listener: endTypeVariable(<, 0, null, null)
28+
reportRecoverableError(List, Message[ExpectedAfterButGot, Expected '>' after this., null, {string: >}])
29+
listener: handleRecoverableError(Message[ExpectedAfterButGot, Expected '>' after this., null, {string: >}], List, List)
30+
parseMetadataStar(<)
31+
ensureIdentifier(<, typeVariableDeclaration)
32+
reportRecoverableErrorWithToken(>>, Instance of 'Template<(Token) => Message>')
33+
rewriter()
34+
listener: endTypeVariables(<, )
35+
parseGetterOrFormalParameters(, Stream, false, MemberKind.TopLevelMethod)
36+
missingParameterMessage(MemberKind.TopLevelMethod)
37+
reportRecoverableError(Stream, MissingFunctionParameters)
38+
listener: handleRecoverableError(MissingFunctionParameters, Stream, Stream)
39+
rewriter()
40+
parseFormalParametersRest((, MemberKind.TopLevelMethod)
41+
listener: beginFormalParameters((, MemberKind.TopLevelMethod)
42+
listener: endFormalParameters(0, (, ), MemberKind.TopLevelMethod)
43+
parseAsyncModifierOpt())
44+
listener: handleAsyncModifier(null, null)
45+
inPlainSync()
46+
parseFunctionBody(), false, false)
47+
ensureBlock(), Instance of 'Template<(Token) => Message>', null)
48+
reportRecoverableError(, Message[ExpectedFunctionBody, Expected a function body, but got ''., null, {token: }])
49+
listener: handleRecoverableError(Message[ExpectedFunctionBody, Expected a function body, but got ''., null, {token: }], , )
50+
insertBlock())
51+
rewriter()
52+
rewriter()
53+
listener: handleInvalidFunctionBody({)
54+
listener: endTopLevelMethod(Stream, null, })
55+
listener: endTopLevelDeclaration()
56+
reportAllErrorTokens(Stream)
57+
listener: endCompilationUnit(1, )
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
NOTICE: Stream was rewritten by parser!
2+
3+
Stream<List<>>>(){}
4+
5+
ERROR: Loop in tokens: (SimpleToken, EOF, 14)) was seen before (linking to (, SyntheticBeginToken, OPEN_PAREN, 14)!
6+
7+
8+
9+
Stream[StringToken]<[BeginToken]List[StringToken]<[BeginToken]>>[SimpleToken][SyntheticStringToken]>[SyntheticToken][SimpleToken]([SyntheticBeginToken])[SyntheticToken]{[SyntheticBeginToken]}[SyntheticToken]
10+
11+
ERROR: Loop in tokens: (SimpleToken, EOF, 14)) was seen before (linking to (, SyntheticBeginToken, OPEN_PAREN, 14)!
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Stream<List<>>
2+
3+
Stream[StringToken]<[BeginToken]List[StringToken]<[BeginToken]>>[SimpleToken][SimpleToken]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stream<List<> >
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Problems reported:
2+
3+
parser/error_recovery/issue_42229_prime.crash:1:8: Expected '>' after this.
4+
Stream<List<> >
5+
^^^^
6+
7+
parser/error_recovery/issue_42229_prime.crash:1:1: A function declaration needs an explicit list of parameters.
8+
Stream<List<> >
9+
^^^^^^
10+
11+
parser/error_recovery/issue_42229_prime.crash:1:16: Expected a function body, but got ''.
12+
Stream<List<> >
13+
^...
14+
15+
beginCompilationUnit(Stream)
16+
beginMetadataStar(Stream)
17+
endMetadataStar(0)
18+
beginTopLevelMember(Stream)
19+
beginTopLevelMethod(, null)
20+
handleNoType()
21+
handleIdentifier(Stream, topLevelFunctionDeclaration)
22+
beginTypeVariables(<)
23+
beginMetadataStar(List)
24+
endMetadataStar(0)
25+
handleIdentifier(List, typeVariableDeclaration)
26+
beginTypeVariable(List)
27+
handleTypeVariablesDefined(List, 1)
28+
handleNoType(List)
29+
endTypeVariable(<, 0, null, null)
30+
handleRecoverableError(Message[ExpectedAfterButGot, Expected '>' after this., null, {string: >}], List, List)
31+
endTypeVariables(<, >)
32+
handleRecoverableError(MissingFunctionParameters, Stream, Stream)
33+
beginFormalParameters((, MemberKind.TopLevelMethod)
34+
endFormalParameters(0, (, ), MemberKind.TopLevelMethod)
35+
handleAsyncModifier(null, null)
36+
handleRecoverableError(Message[ExpectedFunctionBody, Expected a function body, but got ''., null, {token: }], , )
37+
handleInvalidFunctionBody({)
38+
endTopLevelMethod(Stream, null, })
39+
endTopLevelDeclaration()
40+
endCompilationUnit(1, )
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
parseUnit(Stream)
2+
skipErrorTokens(Stream)
3+
listener: beginCompilationUnit(Stream)
4+
syntheticPreviousToken(Stream)
5+
parseTopLevelDeclarationImpl(, Instance of 'DirectiveContext')
6+
parseMetadataStar()
7+
listener: beginMetadataStar(Stream)
8+
listener: endMetadataStar(0)
9+
parseTopLevelMemberImpl()
10+
listener: beginTopLevelMember(Stream)
11+
isReservedKeyword(<)
12+
parseTopLevelMethod(, null, , Instance of 'NoType', null, Stream, false)
13+
listener: beginTopLevelMethod(, null)
14+
listener: handleNoType()
15+
ensureIdentifierPotentiallyRecovered(, topLevelFunctionDeclaration, false)
16+
listener: handleIdentifier(Stream, topLevelFunctionDeclaration)
17+
parseMethodTypeVar(Stream)
18+
listener: beginTypeVariables(<)
19+
parseMetadataStar(<)
20+
listener: beginMetadataStar(List)
21+
listener: endMetadataStar(0)
22+
ensureIdentifier(<, typeVariableDeclaration)
23+
listener: handleIdentifier(List, typeVariableDeclaration)
24+
listener: beginTypeVariable(List)
25+
listener: handleTypeVariablesDefined(List, 1)
26+
listener: handleNoType(List)
27+
listener: endTypeVariable(<, 0, null, null)
28+
reportRecoverableError(List, Message[ExpectedAfterButGot, Expected '>' after this., null, {string: >}])
29+
listener: handleRecoverableError(Message[ExpectedAfterButGot, Expected '>' after this., null, {string: >}], List, List)
30+
parseMetadataStar(<)
31+
ensureIdentifier(<, typeVariableDeclaration)
32+
reportRecoverableErrorWithToken(>, Instance of 'Template<(Token) => Message>')
33+
rewriter()
34+
listener: endTypeVariables(<, >)
35+
parseGetterOrFormalParameters(>, Stream, false, MemberKind.TopLevelMethod)
36+
missingParameterMessage(MemberKind.TopLevelMethod)
37+
reportRecoverableError(Stream, MissingFunctionParameters)
38+
listener: handleRecoverableError(MissingFunctionParameters, Stream, Stream)
39+
rewriter()
40+
parseFormalParametersRest((, MemberKind.TopLevelMethod)
41+
listener: beginFormalParameters((, MemberKind.TopLevelMethod)
42+
listener: endFormalParameters(0, (, ), MemberKind.TopLevelMethod)
43+
parseAsyncModifierOpt())
44+
listener: handleAsyncModifier(null, null)
45+
inPlainSync()
46+
parseFunctionBody(), false, false)
47+
ensureBlock(), Instance of 'Template<(Token) => Message>', null)
48+
reportRecoverableError(, Message[ExpectedFunctionBody, Expected a function body, but got ''., null, {token: }])
49+
listener: handleRecoverableError(Message[ExpectedFunctionBody, Expected a function body, but got ''., null, {token: }], , )
50+
insertBlock())
51+
rewriter()
52+
rewriter()
53+
listener: handleInvalidFunctionBody({)
54+
listener: endTopLevelMethod(Stream, null, })
55+
listener: endTopLevelDeclaration()
56+
reportAllErrorTokens(Stream)
57+
listener: endCompilationUnit(1, )
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
NOTICE: Stream was rewritten by parser!
2+
3+
Stream<List<> >(){}
4+
5+
Stream[StringToken]<[BeginToken]List[StringToken]<[BeginToken][SyntheticStringToken]>[SimpleToken] >[SimpleToken]([SyntheticBeginToken])[SyntheticToken]{[SyntheticBeginToken]}[SyntheticToken][SimpleToken]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Stream<List<> >
2+
3+
Stream[StringToken]<[BeginToken]List[StringToken]<[BeginToken]>[SimpleToken] >[SimpleToken][SimpleToken]

0 commit comments

Comments
 (0)