Skip to content

Commit a4ae2ef

Browse files
committed
Minor cleanup from if to guard statement
I think the guard is a lot easier to read here, noticed while reviewing swiftlang#3171.
1 parent a113ef9 commit a4ae2ef

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Sources/SwiftParser/Lookahead.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ extension Parser.Lookahead {
266266
}
267267

268268
// If we don't have attributes, then it cannot be an accessor block.
269-
if nextToken.rawTokenKind != .atSign {
269+
guard self.peek(isAt: .atSign) else {
270270
return false
271271
}
272272

Tests/SwiftParserTest/DeclarationTests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3768,4 +3768,16 @@ final class UsingDeclarationTests: ParserTestCase {
37683768
"""
37693769
)
37703770
}
3771+
3772+
func testAccessorBlockAfterPatternBindingDeclWithAttribute() {
3773+
assertParse(
3774+
"""
3775+
var x: Int = 2
3776+
{
3777+
@something
3778+
didSet {}
3779+
}
3780+
"""
3781+
)
3782+
}
37713783
}

0 commit comments

Comments
 (0)