-
-
Notifications
You must be signed in to change notification settings - Fork 819
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
refactor: ExprVisitor
type validation
#3739
Conversation
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #3739 +/- ##
==========================================
- Coverage 84.73% 84.61% -0.12%
==========================================
Files 92 92
Lines 13125 13122 -3
Branches 2928 2933 +5
==========================================
- Hits 11121 11103 -18
- Misses 1541 1555 +14
- Partials 463 464 +1 ☔ View full report in Codecov by Sentry. |
vyper/semantics/analysis/local.py
Outdated
if ( | ||
not isinstance(typ, TYPE_T) | ||
and not isinstance(node, (vy_ast.Index, vy_ast.Tuple)) # can be deferred | ||
and not isinstance(node.get_ancestor(), (vy_ast.Expr, vy_ast.Log)) | ||
): |
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.
these are the exceptions that we need to work around, or alternatively it can also be skipped by wrapping the type in a TYPE_T
for Expr
, Log
and Index
nodes.
vyper/semantics/analysis/local.py
Outdated
@@ -690,7 +667,7 @@ def visit_Subscript(self, node: vy_ast.Subscript, typ: VyperType) -> None: | |||
index_types = get_possible_types_from_node(node.slice.value) | |||
index_type = index_types.pop() | |||
|
|||
self.visit(node.slice, index_type) | |||
self.visit(node.slice, TYPE_T(index_type)) |
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.
this probably should be reverted (since removal of the Index ast 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.
nice work, lgtm. thanks!
ExprVisitor
type validation
we should update the InvalidType exception raised in validate_expected_type to raise TypeMismatch instead, but it can be a follow-up PR
What I did
Standardize local visitor to always call
validate_expected_type
in the genericvisit()
, instead of on an ad-hoc basis within the visit for each node.How I did it
How to verify it
Commit message
Description for the changelog
Cute Animal Picture