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 for invalid using for at the top level #1653

Merged
merged 5 commits into from
May 19, 2023

Conversation

bart1e
Copy link
Contributor

@bart1e bart1e commented Feb 9, 2023

This PR implements the detector for the incorrect usage of the using-for statement: in Solidity it is possible to write using <library> for <type> even when <library> does not contain any function that has <type> as its first argument. Such a code will compile even though the statement has no effect.

This detector detects such incorrect usages of using-for statements, currently only for top level using-for statements (#1652 has to be solved in order to implement detector for contract level using-for statements).

It contains several utility functions checking if a certain type may be implicitly convertible to some other one - we can consider moving them to relevant classes (for instance these related to ElementaryType may be added there).

There is one issue though - I wasn't able to get information about the address type: if it's payable or not ("normal" address is not implicitly convertible to address payable, but I am unable to impose this rule right now). Detector now always says that address types are implicitly convertible to each others - it won't bring any false positives, but we may get some false negatives.

@bart1e bart1e force-pushed the detector_for_invalid_using_for branch from 2ad2d7f to 32d4bba Compare May 3, 2023 16:08
@montyly
Copy link
Member

montyly commented May 19, 2023

This is great work, thanks @bart1e

@montyly montyly merged commit e8e1681 into crytic:dev May 19, 2023
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants