Skip to content

Commit f558569

Browse files
committed
Simplify parsing of dollar identifier in argument label position
1 parent c3e644b commit f558569

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

Sources/SwiftParser/Expressions.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,13 +2188,9 @@ extension Parser {
21882188
let unexpectedBeforeLabel: RawUnexpectedNodesSyntax?
21892189
let label: RawTokenSyntax?
21902190
let colon: RawTokenSyntax?
2191-
if let labelAndColon = self.consume(if: { $0.canBeArgumentLabel() }, followedBy: { $0.tokenKind == .colon }) {
2192-
unexpectedBeforeLabel = nil
2193-
(label, colon) = labelAndColon
2194-
} else if let dollarLabelAndColon = self.consume(if: .dollarIdentifier, followedBy: .colon) {
2195-
unexpectedBeforeLabel = RawUnexpectedNodesSyntax([dollarLabelAndColon.0], arena: self.arena)
2196-
label = missingToken(.identifier)
2197-
colon = dollarLabelAndColon.1
2191+
if currentToken.canBeArgumentLabel(allowDollarIdentifier: true) && self.peek().tokenKind == .colon {
2192+
(unexpectedBeforeLabel, label) = parseArgumentLabel()
2193+
colon = consumeAnyToken()
21982194
} else {
21992195
unexpectedBeforeLabel = nil
22002196
label = nil

0 commit comments

Comments
 (0)