Skip to content

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Sep 22, 2025

Also introduces helper predicates getSelfParam and hasSelfParam on the Callable class.

DCA shows a reduction in path resolution inconsistencies, which is expected.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Sep 22, 2025
@hvitved hvitved force-pushed the rust/path-resolution-check-arity branch 2 times, most recently from 569e231 to d4bb0c6 Compare September 22, 2025 13:21
@hvitved hvitved force-pushed the rust/path-resolution-check-arity branch from d4bb0c6 to e6b1e8e Compare September 24, 2025 08:21
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Sep 24, 2025
@hvitved hvitved marked this pull request as ready for review September 24, 2025 11:31
@hvitved hvitved requested a review from a team as a code owner September 24, 2025 11:31
Copilot AI review requested due to automatic review settings September 24, 2025 11:31
Copy link
Contributor

Copilot AI left a 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 PR improves path resolution in Rust analysis by introducing call arity checks to better distinguish between callable items (functions, structs, variants). It adds helper predicates getSelfParam and hasSelfParam to the Callable class and extends path resolution to consider the number of arguments when resolving function calls.

Key changes:

  • Added helper methods for self parameter handling on callable items
  • Introduced CallableItemNode abstract class with arity checks for structs, variants, and functions
  • Enhanced path resolution to match call expressions with their targets based on parameter count

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
HardcodedCryptographicValue.expected Test expectation updates reflecting improved path resolution eliminating duplicates
PathResolutionConsistency.expected Consistency test results showing reduced multiple call target issues
TypeInference.qll Updated to use new getSelfParam() and hasSelfParam() helper methods
PathResolution.qll Core changes adding CallableItemNode class and arity-based call resolution
VariableImpl.qll Updated to use new getSelfParam() helper method
CallableImpl.qll Added getSelfParam() and hasSelfParam() helper methods to Callable class
CallImpl.qll Updated to use new getSelfParam() helper method
ControlFlowGraphImpl.qll Updated to use new getSelfParam() helper method

Copy link
Contributor

@paldepind paldepind left a comment

Choose a reason for hiding this comment

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

Nice reduction in path resolution inconsistencies 👍

arr = super.getNumberOfParams() and
if super.hasSelfParam() then result = arr + 1 else result = arr
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What about adding this to Callable instead as it's not tied to path resolution?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok; calling it getNumberOfParamsInclSelf?

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds very clear 👍


private class VariantItemNode extends ItemNode instanceof Variant {
/** An item that can be called with arguments. */
abstract class CallableItemNode extends ItemNode {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's a bit confusing that CallableItemNode is a function or a struct, when we already have Callable which is a function or a closure. Could we name it something different? Maybe HasParameters?

@hvitved hvitved requested a review from paldepind September 26, 2025 11:16
@hvitved hvitved merged commit 615b0a0 into github:main Sep 26, 2025
18 checks passed
@hvitved hvitved deleted the rust/path-resolution-check-arity branch September 26, 2025 11:45
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 Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants