Skip to content

Commit

Permalink
fix index
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Nov 1, 2023
1 parent 09e5609 commit 311cd26
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 0 additions & 3 deletions vyper/semantics/analysis/pre_typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,6 @@ def visit_Dict(self, node):

def visit_Index(self, node):
self.visit(node.value)
index = get_folded_value(node.value)
if isinstance(index, vy_ast.Constant):
node._metadata["folded_value"] = index

# repeated code for List and Tuple
def _subscriptable_helper(self, node):
Expand Down
3 changes: 3 additions & 0 deletions vyper/semantics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
def get_folded_value(node: vy_ast.VyperNode) -> Optional[vy_ast.VyperNode]:
if isinstance(node, vy_ast.Constant):
return node
elif isinstance(node, vy_ast.Index):
if isinstance(node.value, vy_ast.Constant):
return node.value

return node._metadata.get("folded_value")

0 comments on commit 311cd26

Please sign in to comment.