@@ -395,13 +395,14 @@ ASR::Module_t* load_module(Allocator &al, SymbolTable *symtab,
395
395
396
396
ASR::symbol_t * import_from_module (Allocator &al, ASR::Module_t *m, SymbolTable *current_scope,
397
397
std::string mname, std::string cur_sym_name, std::string new_sym_name,
398
- const Location &loc) {
398
+ const Location &loc, bool skip_current_scope_check= false ) {
399
399
ASR::symbol_t *t = m->m_symtab ->resolve_symbol (cur_sym_name);
400
400
if (!t) {
401
401
throw SemanticError (" The symbol '" + cur_sym_name + " ' not found in the module '" + mname + " '" ,
402
402
loc);
403
403
}
404
- if (current_scope->get_scope ().find (cur_sym_name) != current_scope->get_scope ().end ()) {
404
+ if (!skip_current_scope_check &&
405
+ current_scope->get_scope ().find (cur_sym_name) != current_scope->get_scope ().end ()) {
405
406
throw SemanticError (cur_sym_name + " already defined" , loc);
406
407
}
407
408
if (ASR::is_a<ASR::Function_t>(*t)) {
@@ -4393,10 +4394,14 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
4393
4394
ASRUtils::expr_value (enum_member_variable->m_symbolic_value ));
4394
4395
} else if (ASR::is_a<ASR::Module_t>(*t)) {
4395
4396
ASR::Module_t *m = ASR::down_cast<ASR::Module_t>(t);
4396
- ASR::symbol_t *sym = import_from_module (al, m, current_scope, value,
4397
- x.m_attr , x.m_attr , x.base .base .loc );
4398
- LFORTRAN_ASSERT (ASR::is_a<ASR::ExternalSymbol_t>(*sym));
4399
- current_scope->add_symbol (x.m_attr , sym);
4397
+ std::string sym_name = value + " @" + x.m_attr ;
4398
+ ASR::symbol_t *sym = current_scope->resolve_symbol (sym_name);
4399
+ if (!sym) {
4400
+ sym = import_from_module (al, m, current_scope, value,
4401
+ x.m_attr , sym_name, x.base .base .loc , true );
4402
+ LFORTRAN_ASSERT (ASR::is_a<ASR::ExternalSymbol_t>(*sym));
4403
+ current_scope->add_symbol (sym_name, sym);
4404
+ }
4400
4405
tmp = ASR::make_Var_t (al, x.base .base .loc , sym);
4401
4406
} else {
4402
4407
throw SemanticError (" Only Variable type is supported for now in Attribute" ,
0 commit comments