Skip to content

Commit

Permalink
fix constants dict persistence bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Oct 29, 2023
1 parent 3e40c38 commit 65ab902
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vyper/semantics/analysis/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ def _add_constants_to_namespace(module_nodes: list[vy_ast.VyperNode], ns: Namesp
continue

val = prefold(c.value)
ns.add_constant(name, val)

# note that if a constant is redefined, its value will be overwritten,
# but it is okay because the syntax error is handled downstream
if val is not None:
ns.add_constant(name, val)
derived_nodes += 1
const_var_decls.remove(c)

Expand Down
2 changes: 2 additions & 0 deletions vyper/semantics/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def enter_scope(self):
if len(self._scopes) == 1:
# add mutable vars (`self`) to the initial scope
self.update(environment.get_mutable_vars())
# reset constants
self._constants = {}

return self

Expand Down

0 comments on commit 65ab902

Please sign in to comment.