Skip to content

Commit 82082d1

Browse files
authored
Merge pull request #1614 from ahoppen/ahoppen/5.9/double-right-crash
[5.9] Fix a precondition failure if a generic parameter clause had an additional closing right angle
2 parents d311e73 + 157a296 commit 82082d1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Sources/SwiftParser/Declarations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ extension Parser {
544544

545545
let rangle: RawTokenSyntax
546546
if self.currentToken.starts(with: ">") {
547-
rangle = self.consumeAnyToken(remapping: .rightAngle)
547+
rangle = self.consumePrefix(">", as: .rightAngle)
548548
} else {
549549
rangle = RawTokenSyntax(missing: .rightAngle, arena: self.arena)
550550
}

Tests/SwiftParserTest/DeclarationTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,15 @@ final class DeclarationTests: XCTestCase {
15521552
"""
15531553
)
15541554
}
1555+
1556+
func testDoubleRightAngle() {
1557+
assertParse(
1558+
"func foo<A>1️⃣> test()",
1559+
diagnostics: [
1560+
DiagnosticSpec(message: "unexpected code '> test' before parameter clause")
1561+
]
1562+
)
1563+
}
15551564
}
15561565

15571566
extension Parser.DeclAttributes {

0 commit comments

Comments
 (0)