Skip to content

Type inference: Add support for named arguments - #22973

Draft
hvitved wants to merge 4 commits into
github:mainfrom
hvitved:type-inference-named-args
Draft

hvitved wants to merge 4 commits into
github:mainfrom
hvitved:type-inference-named-args

Conversation

@hvitved

@hvitved hvitved commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions github-actions Bot added Rust Pull requests that update Rust code Unified labels Nov 2, 2026
@hvitved
hvitved force-pushed the type-inference-named-args branch from baaa8f7 to e6d8f96 Compare November 11, 2026 10:15
@hvitved
hvitved requested a max review from Copilot November 11, 2026 10:18

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.

🟡 Changes recommended

Argument matching mishandles repeated Swift labels and labelled enum-case parameters, producing spurious return types and breaking generic type propagation.

2 open issues
What changed in this PR

Adds named-argument matching to shared type inference, enabling Swift to infer argument types when earlier defaulted parameters are omitted.

Changes:

  • Exposes argument names and parameter labels through the inference interfaces.
  • Adds label-based matching while retaining positional arguments for Rust.
  • Updates Swift test annotations and generated inference expectations.
File Description
unified/​ql/​test/​library-tests/​type-inference/​type-inference.expected Records inferred argument-node types and improved closure typing.
unified/​ql/​test/​library-tests/​type-inference/​constructors.swift Updates an inline expectation comment for closure parameter inference.
unified/​ql/​lib/​codeql/​unified/​internal/​typeinference/​TypeInference.qll Introduces named argument wrappers and receiver handling.
unified/​ql/​lib/​codeql/​unified/​internal/​ParameterEx.qll Exposes external names for source and synthesized parameters.
shared/​typeinference/​codeql/​typeinference/​internal/​TypeInference.qll Matches arguments to parameters by name or position.
rust/​ql/​lib/​codeql/​rust/​internal/​typeinference/​TypeInference.qll Adapts positional-only Rust arguments to the shared interface.

Review effort: Max

@hvitved
hvitved force-pushed the type-inference-named-args branch from e6d8f96 to d6d329e Compare November 11, 2026 21:01

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.

🟡 Changes recommended

Unresolved type-inference defects cause label/rank key collisions, misalign repeated-label trailing closures, and block expected-type propagation to function-value call arguments.

3 open issues
2 resolved since last review

Review effort: Max

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.

🟡 Changes recommended

Trailing-closure matching regressions reuse already-consumed parameters for repeated labels and mishandle _ labels, producing incorrect or missing inferred types.

2 open issues
3 resolved since last review

Review effort: Max

@hvitved
hvitved force-pushed the type-inference-named-args branch 2 times, most recently from 099e8b0 to 5033922 Compare November 13, 2026 11:40
@hvitved
hvitved force-pushed the type-inference-named-args branch from 5033922 to c92c120 Compare November 13, 2026 13:55

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Rust Pull requests that update Rust code Unified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants