Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/functional/codegen/modules/test_stateless_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,16 @@ def test_reject_duplicate_imports(make_input_bundle):
compiler.compile_code(contract_source, input_bundle=input_bundle)


def test_reject_duplicate_builtin_imports(make_input_bundle):
contract_source = """
import math
import math as math2
"""
input_bundle = make_input_bundle({"contract.vy": contract_source})
with pytest.raises(DuplicateImport):
compiler.compile_code(contract_source, input_bundle=input_bundle)


def test_nested_module_access(get_contract, make_input_bundle):
lib1 = """
import lib2
Expand Down
6 changes: 3 additions & 3 deletions vyper/semantics/analysis/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ def _add_import(
def _load_import(
self, node: vy_ast.VyperNode, level: int, module_str: str, alias: str
) -> tuple[CompilerInput, Any]:
if _is_builtin(level, module_str):
return _load_builtin_import(level, module_str)

path = _import_to_path(level, module_str)

if path in self.graph.imported_modules:
Expand All @@ -197,6 +194,9 @@ def _load_import(

self.graph.imported_modules[path] = node

if _is_builtin(level, module_str):
return _load_builtin_import(level, module_str)

err = None

try:
Expand Down