Skip to content

Commit ee93aa6

Browse files
committed
[NFC] Tighten checking for PBD introducers
Treating introducers as keywords is now always conditional on whether `shouldParsePatternBinding(introducer:)` returns `true`. That method has also been modified to correctly handle an edge case with wildcard patterns.
1 parent 06f2097 commit ee93aa6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Sources/SwiftParser/Declarations.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ extension TokenConsumer {
163163
}
164164

165165
return true
166+
case .rhs(let introducer):
167+
return subparser.shouldParsePatternBinding(introducer: introducer)
166168
case .some(_):
167169
// All other decl start keywords unconditionally start a decl.
168170
return true

Sources/SwiftParser/Patterns.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,10 @@ extension Parser.Lookahead {
272272
// than likely need to be made contextual as well before finalizing their
273273
// grammar.
274274
case ._borrowing, .borrowing:
275-
return peek(isAt: TokenSpec(.identifier, allowAtStartOfLine: false))
275+
return peek(
276+
isAt: TokenSpec(.identifier, allowAtStartOfLine: false),
277+
TokenSpec(.wildcard, allowAtStartOfLine: false)
278+
)
276279
default:
277280
// Other keywords can be parsed unconditionally.
278281
return true

0 commit comments

Comments
 (0)