Detector for invalid using for at the top level #1653
Merged
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 implements the detector for the incorrect usage of the
using-for
statement: inSolidity
it is possible to writeusing <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 levelusing-for
statements (#1652 has to be solved in order to implement detector for contract levelusing-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'spayable
or not ("normal"address
is not implicitly convertible toaddress payable
, but I am unable to impose this rule right now). Detector now always says thataddress
types are implicitly convertible to each others - it won't bring any false positives, but we may get some false negatives.