Skip to content

Commit a77b337

Browse files
committed
Fix module imports for subroutines
1 parent cf1160b commit a77b337

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5900,6 +5900,21 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
59005900
throw SemanticError("'" + value + "' is not defined in the scope",
59015901
x.base.base.loc);
59025902
}
5903+
if (ASR::is_a<ASR::Module_t>(*t)) {
5904+
std::string call_name = at->m_attr;
5905+
std::string call_name_store = "__" + value + "_" + call_name;
5906+
ASR::Module_t *m = ASR::down_cast<ASR::Module_t>(t);
5907+
call_name_store = ASRUtils::get_mangled_name(m, call_name_store);
5908+
ASR::symbol_t *st = import_from_module(al, m, current_scope, value,
5909+
call_name, call_name_store, x.base.base.loc);
5910+
current_scope->add_symbol(call_name_store, st);
5911+
Vec<ASR::call_arg_t> args;
5912+
args.reserve(al, c->n_args);
5913+
visit_expr_list(c->m_args, c->n_args, args);
5914+
tmp = make_call_helper(al, st, current_scope, args,
5915+
call_name, x.base.base.loc);
5916+
return;
5917+
}
59035918
Vec<ASR::expr_t*> elements;
59045919
elements.reserve(al, c->n_args);
59055920
for (size_t i = 0; i < c->n_args; ++i) {

0 commit comments

Comments
 (0)