Skip to content

Commit 35e2406

Browse files
committed
Check if arrow or leftbrace can be recovered
1 parent d81f0bf commit 35e2406

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Sources/SwiftParser/Declarations.swift

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

13771377
let output: RawReturnClauseSyntax?
1378-
if self.at(.arrow) {
1378+
if let _ = self.canRecoverTo(TokenSpec(.arrow)) {
13791379
output = self.parseFunctionReturnClause(effectSpecifiers: &effectSpecifiers, allowNamedOpaqueResultType: true)
13801380
} else {
13811381
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 self.at(.leftBrace) else {
101+
guard let _ = self.canRecoverTo(TokenSpec(.leftBrace)) else {
102102
return nil
103103
}
104104
return self.parseCodeBlock(allowInitDecl: allowInitDecl)

0 commit comments

Comments
 (0)