Skip to content
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

Detector: Function signature collision #670

Merged
merged 3 commits into from
Aug 19, 2024

Conversation

TilakMaddy
Copy link
Collaborator

@TilakMaddy TilakMaddy commented Aug 17, 2024

In this PR, we rely on the function_selector property being available on the AST Node of type function definition.

Since it's an Optional<String> property, unfortunately in the older solidity versions this is None. So it wouldn't trigger for solc versions ^0.4.0 for example.

Logic:
It groups the function names by their selectors. If we come across a case where there are >= 2 function names for a given selector we capture all the corresponding functions.

Flaw:
The function names could be same but the function parameters vary, then they don't get captured.

Caveat:
This capture happens regardless of whether or not the functions with colliding signatures are are in the same inheritance hierarchy. If they were, the compilation wouldn't be successful in the first place for all the versions that we support (0.4.11 and above).. btw if you compile a 0.4.10 contract even forge bails :)

@TilakMaddy TilakMaddy marked this pull request as ready for review August 17, 2024 04:46
@alexroan alexroan merged commit 9fcabc0 into dev Aug 19, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants