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
hvitved
force-pushed
the
type-inference-named-args
branch
from
November 11, 2026 21:01
e6d8f96 to
d6d329e
Compare
hvitved
force-pushed
the
type-inference-named-args
branch
from
November 11, 2026 21:13
d6d329e to
416224b
Compare
Contributor
There was a problem hiding this comment.
🟡 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
hvitved
force-pushed
the
type-inference-named-args
branch
from
November 12, 2026 19:11
416224b to
3ae6159
Compare
hvitved
force-pushed
the
type-inference-named-args
branch
6 times, most recently
from
November 16, 2026 13:36
48791ee to
dc74749
Compare
hvitved
force-pushed
the
type-inference-named-args
branch
from
November 16, 2026 13:44
dc74749 to
6dff9e0
Compare
hvitved
marked this pull request as ready for review
November 16, 2026 20:11
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.


This PR aligns the interface for parameters and arguments of the type inference library with that of Unified, in order to be able to handle arguments passed in by name. While Swift requires named arguments to respect the parameter declaration order, this is not assumed in the type inference library, which means that the implementation should work for e.g. C# as well.
Swift allows for multiple parameters with the same external name, so we account for that by tagging named arguments/parameters with their rank. However, the following corner-case is not handled:
Since the first trailing closure is not labeled, it gets matched (correctly) by position, but the second trailing closure is considered the first
aargument, so it is also matched against the first parameter instead of the second.This PR also changes the
inferInvocationArgumentTypeContextualDefaultinterface in order to handle contextual propagation into synthetic arguments (documented with a test case).