-
-
Notifications
You must be signed in to change notification settings - Fork 812
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
feat: replace AnnAssign with VariableDef #2881
feat: replace AnnAssign with VariableDef #2881
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2881 +/- ##
==========================================
+ Coverage 88.13% 88.16% +0.02%
==========================================
Files 97 97
Lines 10802 10820 +18
Branches 2562 2569 +7
==========================================
+ Hits 9520 9539 +19
+ Misses 824 823 -1
Partials 458 458
Continue to review full report at Codecov.
|
…/convert_annassign
…/convert_annassign
…/convert_annassign
vyper/semantics/validation/module.py
Outdated
@@ -168,7 +171,7 @@ def visit_AnnAssign(self, node): | |||
|
|||
# generate function type and add to metadata | |||
# we need this when builing the public getter | |||
node._metadata["func_type"] = ContractFunction.from_AnnAssign(node) | |||
node._metadata["func_type"] = ContractFunction.from_VariableDef(node) |
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.
from_VariableDef
could probably be renamed to something like getter_from_VariableDef
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.
looks quite nice. my only question is whether local variables should also be defined with VariableDef
(breaking from python) or stay as AnnAssign
. the extra fields on VariableDef
(is_constant
etc) make a lot of sense on contract variables; not as much on local variables.
I think another approach, taking from I think it would be clearer and more consistent to have both contract and local variable declarations be of |
… into feat/convert_annassign
What I did
Improve conversion of Python AST to Vyper AST.
How I did it
Replace Python's
AnnAssign
nodes for contract variable declarations with a newly introducedVariableDef
Vyper AST node.The
VariableDef
hasfourthree additional attributes, which are set during semantics validation.is_state_variable
is_constant
is_public
is_immutable
How to verify it
See updated tests.
Commit message
Description for the changelog
Add
VariableDef
Vyper AST nodeCute Animal Picture