Skip to content

Commit c800b8d

Browse files
jensjohacommit-bot@chromium.org
authored and
commit-bot@chromium.org
committed
[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 <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
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]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stream<List<>> foo() {}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Problems reported:
2+
3+
parser/error_recovery/issue_42229_prime_2.crash:1:13: Expected a type, but got '>>'.
4+
Stream<List<>> foo() {}
5+
^^
6+
7+
beginCompilationUnit(Stream)
8+
beginMetadataStar(Stream)
9+
endMetadataStar(0)
10+
beginTopLevelMember(Stream)
11+
beginTopLevelMethod(, null)
12+
handleIdentifier(Stream, typeReference)
13+
beginTypeArguments(<)
14+
handleIdentifier(List, typeReference)
15+
beginTypeArguments(<)
16+
handleRecoverableError(Message[ExpectedType, Expected a type, but got '>>'., null, {token: >>}], >>, >>)
17+
handleIdentifier(, typeReference)
18+
handleNoTypeArguments(>>)
19+
handleType(, null)
20+
endTypeArguments(1, <, >)
21+
handleType(List, null)
22+
endTypeArguments(1, <, >)
23+
handleType(Stream, null)
24+
handleIdentifier(foo, topLevelFunctionDeclaration)
25+
handleNoTypeVariables(()
26+
beginFormalParameters((, MemberKind.TopLevelMethod)
27+
endFormalParameters(0, (, ), MemberKind.TopLevelMethod)
28+
handleAsyncModifier(null, null)
29+
beginBlockFunctionBody({)
30+
endBlockFunctionBody(0, {, })
31+
endTopLevelMethod(Stream, null, })
32+
endTopLevelDeclaration()
33+
endCompilationUnit(1, )
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
parseTopLevelMethod(, null, , Instance of 'ComplexTypeInfo', null, foo, false)
12+
listener: beginTopLevelMethod(, null)
13+
ensureIdentifier(, typeReference)
14+
listener: handleIdentifier(Stream, typeReference)
15+
listener: beginTypeArguments(<)
16+
ensureIdentifier(<, typeReference)
17+
listener: handleIdentifier(List, typeReference)
18+
listener: beginTypeArguments(<)
19+
reportRecoverableErrorWithToken(>>, Instance of 'Template<(Token) => Message>')
20+
listener: handleRecoverableError(Message[ExpectedType, Expected a type, but got '>>'., null, {token: >>}], >>, >>)
21+
rewriter()
22+
listener: handleIdentifier(, typeReference)
23+
listener: handleNoTypeArguments(>>)
24+
listener: handleType(, null)
25+
listener: endTypeArguments(1, <, >)
26+
listener: handleType(List, null)
27+
listener: endTypeArguments(1, <, >)
28+
listener: handleType(Stream, null)
29+
ensureIdentifierPotentiallyRecovered(>, topLevelFunctionDeclaration, false)
30+
listener: handleIdentifier(foo, topLevelFunctionDeclaration)
31+
parseMethodTypeVar(foo)
32+
listener: handleNoTypeVariables(()
33+
parseGetterOrFormalParameters(foo, foo, false, MemberKind.TopLevelMethod)
34+
parseFormalParameters(foo, MemberKind.TopLevelMethod)
35+
parseFormalParametersRest((, MemberKind.TopLevelMethod)
36+
listener: beginFormalParameters((, MemberKind.TopLevelMethod)
37+
listener: endFormalParameters(0, (, ), MemberKind.TopLevelMethod)
38+
parseAsyncModifierOpt())
39+
listener: handleAsyncModifier(null, null)
40+
inPlainSync()
41+
parseFunctionBody(), false, false)
42+
listener: beginBlockFunctionBody({)
43+
notEofOrValue(}, })
44+
listener: endBlockFunctionBody(0, {, })
45+
listener: endTopLevelMethod(Stream, null, })
46+
listener: endTopLevelDeclaration()
47+
reportAllErrorTokens(Stream)
48+
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<>> foo() {}
4+
5+
Stream[StringToken]<[BeginToken]List[StringToken]<[BeginToken][SyntheticStringToken]>[SimpleToken]>[SimpleToken] foo[StringToken]([BeginToken])[SimpleToken] {[BeginToken]}[SimpleToken][SimpleToken]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Stream<List<>> foo() {}
2+
3+
Stream[StringToken]<[BeginToken]List[StringToken]<[BeginToken]>>[SimpleToken] foo[StringToken]([BeginToken])[SimpleToken] {[BeginToken]}[SimpleToken][SimpleToken]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stream<List<x>>
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_3.crash:1:8: Expected '>' after this.
4+
Stream<List<x>>
5+
^^^^
6+
7+
parser/error_recovery/issue_42229_prime_3.crash:1:1: A function declaration needs an explicit list of parameters.
8+
Stream<List<x>>
9+
^^^^^^
10+
11+
parser/error_recovery/issue_42229_prime_3.crash:1:17: Expected a function body, but got ''.
12+
Stream<List<x>>
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, )

0 commit comments

Comments
 (0)