Skip to content

Commit

Permalink
fix public constants case
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Sep 23, 2024
1 parent c718e28 commit 8a932a3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions vyper/semantics/types/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ def __init__(
validate_unique_method_ids(list(functions.values()))

constants = constants or {}
public_constants = {
k: varinfo for k, varinfo in constants.items() if varinfo.decl_node.is_public
}

members = functions | events | structs | constants

# sanity check: by construction, there should be no duplicates.
assert len(members) == len(functions) + len(events) + len(structs) + len(constants)
assert len(members) == len(functions) + len(events) + len(structs) + len(constants) - len(
public_constants
)

super().__init__(functions)

Expand Down Expand Up @@ -179,9 +184,15 @@ def _from_lists(

def _mark_seen(name, item):
if name in seen_items:
prev = seen_items[name]
if (
isinstance(prev, ContractFunctionT)
and isinstance(item, VarInfo)
and item.decl_node.is_public
):
return
msg = f"multiple functions or events named '{name}'!"
prev_decl = seen_items[name].decl_node
raise NamespaceCollision(msg, item.decl_node, prev_decl=prev_decl)
raise NamespaceCollision(msg, item.decl_node, prev_decl=prev.decl_node)
seen_items[name] = item

for name, function in function_list:
Expand Down

0 comments on commit 8a932a3

Please sign in to comment.