From a70a024b26cef5bebcfc4b262e00b8fc7d14b077 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Mon, 14 Oct 2024 14:23:16 -0400 Subject: [PATCH] fix[lang]: fix recursive interface imports (#4303) fix a bug where imports inside of interfaces are not recursed into in the import resolution pass. this is a regression in 6843e7915729f3a3ea0d8c765dffa52033f5818e. --- tests/functional/syntax/test_interfaces.py | 13 +++++++++++-- vyper/semantics/analysis/imports.py | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/functional/syntax/test_interfaces.py b/tests/functional/syntax/test_interfaces.py index 20813c48d1..86ea4bcfd0 100644 --- a/tests/functional/syntax/test_interfaces.py +++ b/tests/functional/syntax/test_interfaces.py @@ -381,13 +381,22 @@ def test_interfaces_success(good_code): def test_imports_and_implements_within_interface(make_input_bundle): - interface_code = """ + ibar_code = """ @external def foobar(): ... """ + ifoo_code = """ +import bar - input_bundle = make_input_bundle({"foo.vyi": interface_code}) +implements: bar + +@external +def foobar(): + ... +""" + + input_bundle = make_input_bundle({"foo.vyi": ifoo_code, "bar.vyi": ibar_code}) code = """ import foo as Foo diff --git a/vyper/semantics/analysis/imports.py b/vyper/semantics/analysis/imports.py index be1f2da312..3268f12e94 100644 --- a/vyper/semantics/analysis/imports.py +++ b/vyper/semantics/analysis/imports.py @@ -194,6 +194,7 @@ def _load_import_helper( file = self.input_bundle.load_file(path.with_suffix(".vyi")) assert isinstance(file, FileInput) # mypy hint module_ast = self._ast_from_file(file) + self.resolve_imports(module_ast) # language does not yet allow recursion for vyi files # self.resolve_imports(module_ast)