fix: removed equality method from Literal class #57
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.
Notes
Slither's
Literal
class implements an__eq__
method but not a__hash__
method, making it unhashable. Theeq
implementation was introduced in this PR so that two distinct occurrences ofint[n]
are treated as equal types, wheren
is some literal integer; that was a flawed solution, because it doesn't take into account cases where constants and arithmetic expressions occur in the type expression, e.g.int[CONST_1 + CONST_2]
Another problem with giving
Literal
a custom equality operator is that all otherExpression
subclasses use the built-in equality implementation, which is reference equality. It is confusing to have differentExpression
subclasses using different notions of equality.This PR makes
Literal
hashable by moving the literal equality hack from theLiteral
class into theArrayType
class.Testing
utilities/slither
in a local copy of theslither-task
repo.make test
and verify that all tests succeed./evaluate.sh run 100
and verify that all projects succeedRelated Issue
https://github.com/CertiKProject/slither-task/issues/674
Additional Comments
I created an issue about how giving
Literal
an equality method didn't fix the issue it intended to solve:https://github.com/CertiKProject/slither-task/issues/689
This issue remains unresolved.