-
Notifications
You must be signed in to change notification settings - Fork 979
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
fixed State variables shadowed by a local variable are incorrectly set to the local variable #2060
Conversation
this pull request fixes #2058 |
5cabcb3
to
0de7a25
Compare
Won't this now resolve |
No, it works properly >>> from slither import Slither
>>> a = Slither('a.sol').contracts[0].functions[0]
>>> a.local_variables
[<slither.core.variables.local_variable.LocalVariable object at 0x7ff15a5ac3d0>, <slither.core.variables.local_variable.LocalVariable object at 0x7ff15af1eb50>]
>>> a.nodes[2].variables_read
[<slither.core.variables.local_variable.LocalVariable object at 0x7ff15af1eb50>]
>>> a.nodes[2].variables_read[0]
<slither.core.variables.local_variable.LocalVariable object at 0x7ff15af1eb50>
>>> print(a.nodes[2].variables_read[0])
x |
It works for the compact AST because we have the referenced declaration. I'm not sure how to solve this for legacy AST without reworking name resolution quite a bit You can try it by removing the pragma:
|
When is legacy json considered as default option? |
It is enabled by default for solc 0.4.0 until 0.4.12. Then it must be enabled manually. It was deprecated in 0.8.0 |
I am fine if we don't consider the legacy AST for new fixes moving forward. In the long term we need to rewrite the solc parsing without the legacy AST to reduce complexity, and keep the current parser as "best effort" for the legacy format |
#2121 fixes both |
if variables was not seen before, search for it in the state variables