Skip to content

Commit 057218f

Browse files
committed
Limit conditions for inferencing a possible FuncDecl when met with missing decl syntax inside a member decl list
1 parent 13f113e commit 057218f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/SwiftParser/Declarations.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,11 @@ extension Parser {
281281
)
282282
}
283283

284-
let isProbablyFuncDecl = self.at(.identifier, .wildcard) || self.at(anyIn: Operator.self) != nil
284+
let isPossibleFuncIdentifier = self.at(.identifier, .wildcard)
285+
let isPossibleFuncParen = self.peek(isAt: .identifier, .leftParen) || self.peek(isAt: .identifier, .leftAngle)
285286

286-
if isProbablyFuncDecl {
287+
// Treat operators specially because they're likely to be functions.
288+
if (isPossibleFuncIdentifier && isPossibleFuncParen) || self.at(anyIn: Operator.self) != nil {
287289
return RawDeclSyntax(self.parseFuncDeclaration(attrs, .missing(.keyword(.func))))
288290
}
289291
}

0 commit comments

Comments
 (0)