-
Notifications
You must be signed in to change notification settings - Fork 982
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
Uninitialised local vars bug fixed #1533
Conversation
Can you add the example from OP's issue as a regression test and document why the "name" is being overwritten in a code comment please? |
@0xalpharush Sure, I will do that. Where should I put the test? In |
Both would be awesome! But at least testing the detector behavior in |
59f7966
to
2790e76
Compare
@0xalpharush I have added both tests as requested. |
Oooh, I found this change worked, too.
|
Replaced by #1912 |
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.