Skip to content

Commit f5675f5

Browse files
committed
Add args in the new recovery function callings
1 parent 19201fa commit f5675f5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Sources/SwiftParser/Declarations.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,8 @@ extension Parser {
13751375
var effectSpecifiers = self.parseDeclEffectSpecifiers()
13761376

13771377
let output: RawReturnClauseSyntax?
1378-
if let _ = self.canRecoverTo(TokenSpec(.arrow)) {
1378+
1379+
if self.at(.arrow) || self.canRecoverTo(TokenSpec(.arrow, recoveryPrecedence: .weakPunctuator, allowAtStartOfLine: false)) != nil {
13791380
output = self.parseFunctionReturnClause(effectSpecifiers: &effectSpecifiers, allowNamedOpaqueResultType: true)
13801381
} else {
13811382
output = nil

Sources/SwiftParser/TopLevel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ extension Parser {
9898
/// This function is used when parsing places where function bodies are
9999
/// optional - like the function requirements in protocol declarations.
100100
mutating func parseOptionalCodeBlock(allowInitDecl: Bool = true) -> RawCodeBlockSyntax? {
101-
guard let _ = self.canRecoverTo(TokenSpec(.leftBrace)) else {
101+
guard self.at(.leftBrace) || self.canRecoverTo(TokenSpec(.leftBrace, allowAtStartOfLine: false)) != nil else {
102102
return nil
103103
}
104104
return self.parseCodeBlock(allowInitDecl: allowInitDecl)

0 commit comments

Comments
 (0)