-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rust: Account for disambiguation in path resolution tests #21261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request updates the path resolution tests to properly account for disambiguation when resolving function call paths in Rust. The changes use CallExpr.getResolvedTarget() instead of resolvePath() for paths that are function expressions in call sites, which provides more accurate resolution when multiple implementations are available.
Changes:
- Modified the path resolution query and test utility to use
getResolvedTarget()for call expression function paths - Updated test expectations to reflect the new, more accurate path resolutions
- Updated test input comments to document expected vs. spurious resolutions
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| rust/ql/test/library-tests/path-resolution/path-resolution.ql | Added logic to distinguish call expression paths and use getResolvedTarget() for disambiguation |
| rust/ql/lib/utils/test/PathResolutionInlineExpectationsTest.qll | Applied the same disambiguation logic to the inline expectations test |
| rust/ql/test/library-tests/path-resolution/path-resolution.expected | Updated expected test results to reflect the new resolution behavior |
| rust/ql/test/library-tests/path-resolution/main.rs | Updated test comments to reflect which resolutions are now found vs. missing |
| or | ||
| exists(CallExpr ce | | ||
| p = ce.getFunction().(PathExpr).getPath() and | ||
| i = ce.getResolvedTarget() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I think this belongs here.
I'd expect these tests to only be testing path resolution and this resolvePath predicate to reflect path resolution's resolvePath
By using getResolvedTarget we're now testing type inference + method resolution as well which seems like a conflation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll only make the change to PathResolutionInlineExpectationsTest.qll.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that I wasn't clear enough, but I have the same thoughts about the change in PathResolutionInlineExpectationsTest.qll
I think it's worthwhile that the tests for path resolution document the state of resolvePath and that the further refinements done by type inference is documented by the tests for type inference.
As an example, some of the annotations touched by this PR are also changed by #21247. There it's useful that one can see exactly how the changes to path resolution affects resolvePath independently of type inference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, though it is a bit of a shame that some of the inline expectations indicate shortcomings fixed by type inference or shortcomings not covered by type inference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We could add comments in the places where gaps are not covered by type inference?
And btw, #21253 is the PR I meant to link to above. I think that PR addresses the as paths by making it clear what path resolution is responsible for for such paths.
9c483cd to
3e362be
Compare
|
Will do #21282 instead. |
No description provided.