Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upObfuscate variable names generated by the compiler #1601
Conversation
This blocks the user from creating a collision with a compiler-generated variable at the parser level.
@@ -146,8 +146,8 @@ def is_valid_varname(self, name, pos): | |||
|
|||
# TODO location info for errors | |||
# Add a new variable | |||
def new_variable(self, name, typ, pos=None): | |||
if self.is_valid_varname(name, pos): | |||
def new_variable(self, name, typ, anon=False, pos=None): |
This comment has been minimized.
This comment has been minimized.
davesque
Sep 5, 2019
Contributor
Should we rename anon
to be something more descriptive? For example, maybe we could have check_varname=True
instead. It would also be nice to add a note about why that option exists and why it's useful.
This comment has been minimized.
This comment has been minimized.
davesque
Sep 5, 2019
•
Contributor
I'm also seeing a couple of other places (like here) where internal variables are being created without the new_placeholder
method. So it might actually make more sense to have a new method, new_internal_variable
, which does the variable name mangling and ensures that the provided name won't collide with the namespace in the vyper source file. Then new_placeholder
could just make a call to that without manually mangling its variable name.
This comment has been minimized.
This comment has been minimized.
charles-cooper
Sep 6, 2019
Author
Collaborator
Good catch and suggestion. I'm thinking of just putting the mangling option into new_variable instead of a whole new function.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@davesque anything else you would like to see on this? |
charles-cooper commentedSep 5, 2019
•
edited
This blocks the user from creating a collision with a compiler-generated
variable at the parser level.
What I did
Fix #1600
How I did it
How to verify it
Description for the changelog
Cute Animal Picture