yandex / yandex/implicits

Static analyzer does not handle multiple trailing closures

Open
#43 0 comments 0 reactions 0 assignees View on GitHub

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
  1. Extend SyntaxTree.FunctionCall to model additional trailing closures
  2. Update FunctionCallExprSyntax.syntaxDescription to populate them
  3. Update SemaTreeBuilder.visit(functionCall:) to visit additional trailing closures
  4. Consider which closures should inherit scope in Context.isImmediateClosureCall

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.