diff --git a/Sources/SwiftParser/Lookahead.swift b/Sources/SwiftParser/Lookahead.swift index 4c16f78b8b9..5a6157903ab 100644 --- a/Sources/SwiftParser/Lookahead.swift +++ b/Sources/SwiftParser/Lookahead.swift @@ -266,7 +266,7 @@ extension Parser.Lookahead { } // If we don't have attributes, then it cannot be an accessor block. - if nextToken.rawTokenKind != .atSign { + guard self.peek(isAt: .atSign) else { return false } diff --git a/Tests/SwiftParserTest/DeclarationTests.swift b/Tests/SwiftParserTest/DeclarationTests.swift index 5abae62a131..2034223ac5a 100644 --- a/Tests/SwiftParserTest/DeclarationTests.swift +++ b/Tests/SwiftParserTest/DeclarationTests.swift @@ -3768,4 +3768,16 @@ final class UsingDeclarationTests: ParserTestCase { """ ) } + + func testAccessorBlockAfterPatternBindingDeclWithAttribute() { + assertParse( + """ + var x: Int = 2 + { + @something + didSet {} + } + """ + ) + } }