Skip to content

Unified: Fix translation of wildcard patterns - #22664

Merged
asgerf merged 3 commits into
github:mainfrom
asgerf:unified/wildcard_pattern
Sep 24, 2026
Merged

asgerf merged 3 commits into
github:mainfrom
asgerf:unified/wildcard_pattern

Conversation

@asgerf

@asgerf asgerf commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@asgerf
asgerf marked this pull request as ready for review September 23, 2026 12:48
@asgerf
asgerf requested review from a team as code owners September 23, 2026 12:48
Copilot AI balanced review requested due to automatic review settings September 23, 2026 12:48

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.

Copilot review overview

🟡 Changes recommended

Ignored parameters and labeled enum-case wildcards are still translated as identifiers.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds a dedicated unified AST node for Swift wildcard and discard patterns.

Changes:

  • Adds ignore_pattern to the schema and generated QL definitions.
  • Updates Swift translation rules and corpus expectations.
File Reviewed change
unified/​ql/​lib/​unified.dbscheme Registers the new schema type.
unified/​ql/​lib/​codeql/​unified/​internal/​Ast.qll Exposes IgnorePattern to QL.
unified/​extractor/​tests/​corpus/​swift/​operators/​unresolved-operator-sequence.output Updates wildcard expectations.
unified/​extractor/​tests/​corpus/​swift/​operators/​unresolved-operator-sequence-with-casts.output Updates wildcard expectations involving casts.
unified/​extractor/​tests/​corpus/​swift/​expressions/​super-expression.output Updates discard-assignment expectations.
unified/​extractor/​src/​languages/​swift/​swift.rs Adds wildcard translation rules; some parameter and labeled enum-case forms remain unhandled.
unified/​extractor/​ast_types.yml Defines ignore_pattern; closure shorthand mapping still emits _ as an identifier.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

// the target AST represents it as a `name_node` over the `_` token.
rule!((discardAssignmentExpr wildcard: @@w) => (identifier #{w})),
// assignment `_ = x`. swift-syntax models it as a `discardAssignmentExpr`.
rule!((discardAssignmentExpr wildcard: @@w) => (ignore_pattern #{w})),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. This is already fixed in #22657 since it removes the nested rule, so I'll wait for that to merge first.

hvitved
hvitved previously approved these changes Sep 23, 2026
@asgerf asgerf added the no-change-note-required This PR does not need a change note label Sep 23, 2026
@asgerf
asgerf merged commit a7db2a7 into github:main Sep 24, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants