Obfuscate 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.
| # 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): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Good catch and suggestion. I'm thinking of just putting the mangling option into new_variable instead of a whole new function.
find all places where internal variables get created and set the flag to mangle.
|
@davesque anything else you would like to see on this? |
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