Skip to content

Commit

Permalink
fix: skip enum members during constant folding (#3235)
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg authored Jan 20, 2023
1 parent de3ec9f commit d59ffaa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/parser/syntax/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ def run() -> Order:
})
""",
"enum Foo:\n" + "\n".join([f" member{i}" for i in range(256)]),
"""
a: constant(uint256) = 1
enum A:
a
""",
]


Expand Down
4 changes: 4 additions & 0 deletions vyper/ast/folding.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ def replace_constant(
if assign and node in assign.target.get_descendants(include_self=True):
continue

# do not replace enum members
if node.get_ancestor(vy_ast.EnumDef):
continue

try:
# note: _replace creates a copy of the replacement_node
new_node = _replace(node, replacement_node, type_=type_)
Expand Down

0 comments on commit d59ffaa

Please sign in to comment.