Repository navigation
Conversation
hvitved
force-pushed
the
type-inference-named-args
branch
from
November 11, 2026 10:15
baaa8f7 to
e6d8f96
Compare
Contributor
There was a problem hiding this comment.
🟡 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
| pragma[nomagic] | ||
| additional AccessPosition getArgumentPosition(Invocation i, Argument arg) { | ||
| exists(int pos | arg = i.getArgument(pos) | | ||
| result.asNamed() = arg.getName() |
|
|
||
| AstParameterEx() { this = TAstParameter(p) } | ||
|
|
||
| override string getExternalName() { result = p.getExternalName() } |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.