Static analyzer does not handle multiple trailing closures
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 43
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
The SyntaxTree.FunctionCall model only captures a single trailingClosure. Swift's multiple trailing closure syntax (additional trailing closures) is silently dropped during syntax tree building (SyntaxTreeBuilder.swift, FunctionCallExprSyntax.syntaxDescription).
This means:
- Closures passed as additional trailing closures are invisible to the static analyzer
- For immediate closure support, only the first trailing closure is checked — additional closure arguments are not analyzed
Example
UIView.animate(withDuration: 0.3) {
// animations — this is the trailing closure, currently captured
} completion: { finished in
// completion — this is an additional trailing closure, currently dropped
}
Steps
- Extend
SyntaxTree.FunctionCallto model additional trailing closures - Update
FunctionCallExprSyntax.syntaxDescriptionto populate them - Update
SemaTreeBuilder.visit(functionCall:)to visit additional trailing closures - Consider which closures should inherit scope in
Context.isImmediateClosureCall
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with SyntaxTreeBuilder.swift, FunctionCallExprSyntax.syntaxDescription, and SemaTreeBuilder.visit(functionCall:), then trace Context.isImmediateClosureCall for the scope question. Use the UIView.animate example to verify that both the trailing and additional trailing closures are represented and analyzed, with the intended scope behavior confirmed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100