-
Notifications
You must be signed in to change notification settings - Fork 1k
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
#2586 use enum to track variable location instead of string #2682
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way it's done at the moment the location value wouild still be the string that's for example why you have to use the Enum value in the comparisons. You should make the location the actual Enum when it's set which means going where set_location
is called and passing the enum's variant as argument. For example myvar.set_location(VariableLocation("memory"))
would set myvar's location to VariableLocation.MEMORY not "memory" the string. After that you would need to check all the places where location
is used and if it's used in a comparison (like myvar.location == "memory"
) you need to change it to compare it against the enum variant (myvar.location == VariableLocation.MEMORY
). This for both LocalVariable
and StateVariable
.
from slither.core.solidity_types.user_defined_type import UserDefinedType | ||
from slither.core.solidity_types.mapping_type import MappingType | ||
from slither.core.solidity_types.elementary_type import ElementaryType | ||
import enum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please import only Enum from enum and not the entire module
|
||
if TYPE_CHECKING: # type: ignore | ||
from slither.core.declarations import Function | ||
|
||
|
||
class VariableLocation(enum.Enum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's missing a possible field DEFAULT = "default"
. I would move this class in variable.py since it's used also by state_variable and seems a better place to have it.
No description provided.