From fe14ef07a3658e03c07dd19ca0fceba4ec1c1a91 Mon Sep 17 00:00:00 2001 From: Alex Hoppen Date: Thu, 27 Apr 2023 17:54:56 -0700 Subject: [PATCH] Fix a precondition failure if a generic parameter clause had an additional closing right angle rdar://108624264 --- Sources/SwiftParser/Declarations.swift | 2 +- Tests/SwiftParserTest/DeclarationTests.swift | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftParser/Declarations.swift b/Sources/SwiftParser/Declarations.swift index 07d3fcdf6fa..84402934b55 100644 --- a/Sources/SwiftParser/Declarations.swift +++ b/Sources/SwiftParser/Declarations.swift @@ -544,7 +544,7 @@ extension Parser { let rangle: RawTokenSyntax if self.currentToken.starts(with: ">") { - rangle = self.consumeAnyToken(remapping: .rightAngle) + rangle = self.consumePrefix(">", as: .rightAngle) } else { rangle = RawTokenSyntax(missing: .rightAngle, arena: self.arena) } diff --git a/Tests/SwiftParserTest/DeclarationTests.swift b/Tests/SwiftParserTest/DeclarationTests.swift index e8062c54128..30e6b79ffd5 100644 --- a/Tests/SwiftParserTest/DeclarationTests.swift +++ b/Tests/SwiftParserTest/DeclarationTests.swift @@ -1610,6 +1610,15 @@ final class DeclarationTests: XCTestCase { ) ) } + + func testDoubleRightAngle() { + assertParse( + "func foo1️⃣> test()", + diagnostics: [ + DiagnosticSpec(message: "unexpected code '> test' before parameter clause") + ] + ) + } } extension Parser.DeclAttributes {