Uninitialised local vars bug fixed #1533
Closed
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.
Fixes #1505.
There is a bug in
_parse_variable_definition
when handling tuples in expressions like(type1 a, type2 b) = f()
.It manifests itself when we have two variables named the same in different scopes and when they are defined in an expression like the one above.
The problem is that
slither
renames variables with the same names in different scopes, but while handling such expressions, an additional expression is created, but it contains old variable names. Code responsible for doing this is depicted below:It causes
slither
to think that the same variables are referenced in all scopes and it makes bothslithir
representation and further variable analysis incorrect.I have suggested the simplest fix, that is, to modify the
src
variable so that the code executed afterwards (pasted above) creates anExpression
with correct variable names. But, if we don't want to modifysrc
, we may store all new variable names in a list and then use it when initialising theidentifier
variable.