diff --git a/jaclang/compiler/passes/main/import_pass.py b/jaclang/compiler/passes/main/import_pass.py index 64f726baa..aac33b8cf 100644 --- a/jaclang/compiler/passes/main/import_pass.py +++ b/jaclang/compiler/passes/main/import_pass.py @@ -14,7 +14,7 @@ from jaclang.compiler.passes import Pass from jaclang.compiler.passes.main import SubNodeTabPass, SymTabBuildPass from jaclang.utils.log import logging - +from jaclang.compiler.constant import SymbolType logger = logging.getLogger(__name__) @@ -287,6 +287,14 @@ def import_py_module( self.import_table[file_to_raise] = mod self.attach_mod_to_node(parent_node, mod) SymTabBuildPass(input_ir=mod, prior=self) + parent_node.sym_tab.insert( + ast.AstSymbolNode( + sym_name=imported_mod_name, + name_spec=mod.kid[0].name_spec, + sym_category=SymbolType.MOD_VAR, + ), + access_spec=None, + ) return mod else: raise self.ice(f"Failed to import python module {mod_path}") diff --git a/jaclang/compiler/passes/main/sym_tab_build_pass.py b/jaclang/compiler/passes/main/sym_tab_build_pass.py index 5dbfa4e59..a29392127 100644 --- a/jaclang/compiler/passes/main/sym_tab_build_pass.py +++ b/jaclang/compiler/passes/main/sym_tab_build_pass.py @@ -195,15 +195,10 @@ def exit_import(self, node: ast.Import) -> None: sub_module: Optional[Module], """ if not node.is_absorb: - # if node.from_loc: - # print('--',node.from_loc.sym_name ) for i in node.items.items: - # print('i.symname ----',i.sym_name) if not isinstance(i, ast.ModuleItem): - # print('-mod path----',i.sym_name) continue if not i.from_mod_path.sub_module: - # print('-no sub mod----',i.sym_name) continue lookup = i.from_mod_path.sub_module.sym_tab.lookup(i.name.value) if lookup: @@ -211,7 +206,6 @@ def exit_import(self, node: ast.Import) -> None: node.sym_tab.insert(lookup.decl, lookup.access) else: i.sym_tab.def_insert(i, single_decl="import item") - # print(i.sym_name) # if not node.is_absorb: # for i in node.items.items: