Skip to content

Commit 539d315

Browse files
committed
Exclude .wildcardKeyword from remapping and Add test for wildcard
1 parent e8d9674 commit 539d315

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Sources/SwiftParser/Names.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ extension Parser {
3131
self.missingToken(.identifier, text: nil)
3232
)
3333
} else {
34+
if let wildcardToken = self.consume(if: .wildcardKeyword) {
35+
return (nil, wildcardToken)
36+
}
3437
return (nil, self.consumeAnyToken(remapping: .identifier))
3538
}
3639
}

Tests/SwiftParserTest/DeclarationTests.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,22 @@ final class DeclarationTests: XCTestCase {
7373
)
7474

7575
AssertParse("func /^ (lhs: Int, rhs: Int) -> Int { 1 / 2 }")
76+
77+
AssertParse(
78+
"""
79+
func name(_ default: Int) {}
80+
""",
81+
substructure: Syntax(FunctionParameterSyntax(
82+
attributes: nil,
83+
modifiers: nil,
84+
firstName: .wildcardKeyword(),
85+
secondName: .identifier("default"),
86+
colon: TokenSyntax.colonToken(),
87+
type: TypeSyntax(SimpleTypeIdentifierSyntax(name: TokenSyntax.identifier("Int"), genericArgumentClause: nil)),
88+
ellipsis: nil,
89+
defaultArgument: nil,
90+
trailingComma: nil))
91+
)
7692
}
7793

7894
func testFuncAfterUnbalancedClosingBrace() {

0 commit comments

Comments
 (0)