@@ -4472,10 +4472,6 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
4472
4472
throw SemanticError (" Not implemented: The import statement must currently specify the module name" , x.base .base .loc );
4473
4473
}
4474
4474
std::string msym = x.m_module ; // Module name
4475
- std::vector<std::string> mod_symbols;
4476
- for (size_t i=0 ; i<x.n_names ; i++) {
4477
- mod_symbols.push_back (x.m_names [i].m_name );
4478
- }
4479
4475
4480
4476
// Get the module, for now assuming it is not loaded, so we load it:
4481
4477
ASR::symbol_t *t = nullptr ; // current_scope->parent->resolve_symbol(msym);
@@ -4518,13 +4514,17 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
4518
4514
}
4519
4515
4520
4516
ASR::Module_t *m = ASR::down_cast<ASR::Module_t>(t);
4521
- int i=-1 ;
4522
- for (auto &remote_sym : mod_symbols) {
4517
+ int i = -1 ;
4518
+ for (size_t j=0 ; j<x.n_names ; j++) {
4519
+ std::string remote_sym = x.m_names [j].m_name ;
4523
4520
i++;
4524
4521
if ( procedures_db.is_function_to_be_ignored (msym, remote_sym) ) {
4525
4522
continue ;
4526
4523
}
4527
4524
std::string new_sym_name = ASRUtils::get_mangled_name (m, remote_sym);
4525
+ if (x.m_names [j].m_asname ) {
4526
+ new_sym_name = ASRUtils::get_mangled_name (m, x.m_names [j].m_asname );
4527
+ }
4528
4528
ASR::symbol_t *t = import_from_module (al, m, current_scope, msym,
4529
4529
remote_sym, new_sym_name, x.m_names [i].loc , true );
4530
4530
if (current_scope->get_scope ().find (new_sym_name) != current_scope->get_scope ().end ()) {
@@ -4914,7 +4914,12 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
4914
4914
// Handled by SymbolTableVisitor already
4915
4915
std::string mod_name = x.m_module ;
4916
4916
for (size_t i = 0 ; i < x.n_names ; i++) {
4917
- imported_functions[x.m_names [i].m_name ] = mod_name;
4917
+ if (x.m_names [i].m_asname ) {
4918
+ imported_functions[x.m_names [i].m_asname ] = mod_name;
4919
+ }
4920
+ else {
4921
+ imported_functions[x.m_names [i].m_name ] = mod_name;
4922
+ }
4918
4923
}
4919
4924
ASR::symbol_t *mod_sym = current_scope->resolve_symbol (mod_name);
4920
4925
if (mod_sym) {
0 commit comments