Skip to content

Unified, Swift: Translate ignored parameters into ignore patterns - #23050

Merged
paldepind merged 2 commits into
mainfrom
unified/anonymous-identifier
Nov 9, 2026
Merged

paldepind merged 2 commits into
mainfrom
unified/anonymous-identifier

Conversation

@paldepind

@paldepind paldepind commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

In Swift parameters that are named _ are ignored and not accessible within the body of the function: https://docs.swift.org/latest/documentation/the-swift-programming-language/declarations/#Special-Kinds-of-Parameters

This PR translates such anonymous local parameter names to ignore patterns instead of identifiers.

@paldepind paldepind changed the title Unified: translate anonymous Swift parameters as ignore patterns Unified, Swift: Translate ignored parameters into ignore patterns Nov 9, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 49ef7786-959a-40d6-861f-3dcd71a73665
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 49ef7786-959a-40d6-861f-3dcd71a73665
@paldepind
paldepind force-pushed the unified/anonymous-identifier branch from ae7d1a3 to fbef21d Compare November 9, 2026 09:04
@paldepind
paldepind marked this pull request as ready for review November 9, 2026 09:31
@paldepind
paldepind requested a review from a team as a code owner November 9, 2026 09:31
Copilot AI auto review requested due to automatic review settings November 9, 2026 09:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change to represent anonymous Swift parameters as ignore patterns.

No open issues 🎉

What changed in this PR

This PR updates the unified Swift extractor to represent anonymous local parameters (_) as ignore patterns rather than identifiers, matching Swift’s parameter semantics.

Changes:

  • Applies shared parameter-pattern translation to functions and typed and shorthand closures.
  • Adds coverage for anonymous parameters, including those with external argument labels.
  • Updates existing expected outputs to reflect ignore patterns.
File Description
unified/​extractor/​tests/​corpus/​swift/​types/​function-type-with-inout-parameter.output Updates the expected anonymous closure parameter pattern.
unified/​extractor/​tests/​corpus/​swift/​functions/​function-with-anonymous-parameters.swift Adds anonymous function and closure parameter cases.
unified/​extractor/​tests/​corpus/​swift/​functions/​function-with-anonymous-parameters.output Records expected translation for the new cases.
unified/​extractor/​tests/​corpus/​swift/​expressions/​array-type-constructor.output Updates the ignored closure parameter expectation.
unified/​extractor/​src/​languages/​swift/​swift.rs Adds and applies shared translation from _ parameters to ignore patterns.

Review effort: Balanced (auto)

@tausbn tausbn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! 👍

@paldepind
paldepind merged commit 65865d0 into main Nov 9, 2026
11 checks passed
@paldepind
paldepind deleted the unified/anonymous-identifier branch November 9, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants