Skip to content

Commit 026d472

Browse files
committed
Let recovery respect to allowAtStartOfLine
1 parent 6057c0b commit 026d472

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Sources/SwiftParser/Declarations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ extension Parser {
13761376

13771377
let output: RawReturnClauseSyntax?
13781378

1379-
if self.at(.arrow) || self.canRecoverTo(TokenSpec(.arrow, recoveryPrecedence: .weakPunctuator, allowAtStartOfLine: false)) != nil {
1379+
if self.at(.arrow) || self.canRecoverTo(TokenSpec(.arrow, allowAtStartOfLine: false)) != nil {
13801380
output = self.parseFunctionReturnClause(effectSpecifiers: &effectSpecifiers, allowNamedOpaqueResultType: true)
13811381
} else {
13821382
output = nil

Sources/SwiftParser/Recovery.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ extension Parser.Lookahead {
7070
let initialTokensConsumed = self.tokensConsumed
7171

7272
let recoveryPrecedence = min(spec1.recoveryPrecedence, spec2.recoveryPrecedence, spec3.recoveryPrecedence)
73+
let shouldSkipOverNewlines = recoveryPrecedence.shouldSkipOverNewlines && spec1.allowAtStartOfLine && spec2.allowAtStartOfLine && spec3.allowAtStartOfLine
7374

7475
while !self.at(.eof) {
75-
if !recoveryPrecedence.shouldSkipOverNewlines, self.currentToken.isAtStartOfLine {
76+
if !shouldSkipOverNewlines, self.currentToken.isAtStartOfLine {
7677
break
7778
}
7879
let matchedSpec: TokenSpec?

0 commit comments

Comments
 (0)