Skip to content

Commit b769363

Browse files
committed
Modify tokenKind comparison logic to use "at" function
1 parent 192d7af commit b769363

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Sources/SwiftParser/Expressions.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,13 @@ extension Parser {
318318
)
319319

320320
let rhs: RawExprSyntax?
321-
if colon.isMissing,
322-
currentToken.rawTokenKind != currentToken.cursor.previousTokenKind {
323-
rhs = RawExprSyntax(RawMissingExprSyntax(arena: self.arena))
321+
if colon.isMissing {
322+
if let previousTokenKind = currentToken.cursor.previousTokenKind,
323+
self.at(TokenSpec(previousTokenKind)) {
324+
rhs = nil
325+
} else {
326+
rhs = RawExprSyntax(RawMissingExprSyntax(arena: self.arena))
327+
}
324328
} else {
325329
rhs = nil
326330
}

0 commit comments

Comments
 (0)