Skip to content

Commit

Permalink
fix: bad assertion in expr.py (#3758)
Browse files Browse the repository at this point in the history
in addition to structs and interfaces, some builtins can also be skipped
by the constant folder.
  • Loading branch information
charles-cooper authored Feb 5, 2024
1 parent db8ac3c commit f7f67d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 7 additions & 0 deletions tests/functional/syntax/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ def deposit(deposit_input: Bytes[2048]):
CONST_BAR: constant(Foo) = Foo({a: 1, b: 2})
""",
"""
CONST_EMPTY: constant(bytes32) = empty(bytes32)
@internal
def foo() -> bytes32:
return CONST_EMPTY
""",
"""
struct Foo:
a: uint256
b: uint256
Expand Down
3 changes: 0 additions & 3 deletions vyper/codegen/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ def parse_Name(self):
varinfo = self.context.globals[self.expr.id]

if varinfo.is_constant:
# constants other than structs and interfaces should have already gotten
# propagated during constant folding
assert isinstance(varinfo.typ, (InterfaceT, StructT))
return Expr.parse_value_expr(varinfo.decl_node.value, self.context)

assert varinfo.is_immutable, "not an immutable!"
Expand Down

0 comments on commit f7f67d0

Please sign in to comment.