Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 088c4df

Browse files
committedMar 19, 2025·
Bug fix moved dependency addition to import body visitor
1 parent 6b7ba73 commit 088c4df

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed
 

‎src/lpython/semantics/python_ast_to_asr.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -4910,6 +4910,16 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
49104910
throw SemanticError("The module '" + mod_sym + "' cannot be loaded",
49114911
x.base.base.loc);
49124912
}
4913+
if( mod_sym == "__init__" ) {
4914+
for( auto item: ASRUtils::symbol_symtab(t)->get_scope() ) {
4915+
if( ASR::is_a<ASR::ExternalSymbol_t>(*item.second) ) {
4916+
current_module_dependencies.push_back(al,
4917+
ASR::down_cast<ASR::ExternalSymbol_t>(item.second)->m_module_name);
4918+
}
4919+
}
4920+
} else {
4921+
current_module_dependencies.push_back(al, s2c(al, mod_sym));
4922+
}
49134923
}
49144924
}
49154925

@@ -5115,13 +5125,6 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
51155125
tmp_vec.clear();
51165126
visit_stmt(*x.m_body[i]);
51175127

5118-
if (x.m_body[i]->type == LCompilers::LPython::AST::stmtType::Import){
5119-
AST::Import_t import = (const AST::Import_t &) *x.m_body[i];
5120-
for (size_t j=0;j<import.n_names;j++) {
5121-
current_module_dependencies.push_back(al, import.m_names[i].m_name);
5122-
}
5123-
}
5124-
51255128
for (auto t: global_init) {
51265129
if (t) {
51275130
items.push_back(al, t);

0 commit comments

Comments
 (0)
Please sign in to comment.