@@ -341,9 +341,15 @@ namespace LCompilers {
341341 SymbolTable* temp_scope = current_scope;
342342
343343 if (asr_owner_sym && temp_scope->get_counter () != ASRUtils::symbol_parent_symtab (x.m_name )->get_counter () &&
344- !ASR::is_a<ASR::AssociateBlock_t>(*asr_owner_sym) && !ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name ) &&
345- !ASR::is_a<ASR::Variable_t>(*x.m_name )) {
346- function_dependencies.push_back (al, ASRUtils::symbol_name (x.m_name ));
344+ !ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name ) && !ASR::is_a<ASR::Variable_t>(*x.m_name )) {
345+ if (ASR::is_a<ASR::AssociateBlock_t>(*asr_owner_sym) || ASR::is_a<ASR::Block_t>(*asr_owner_sym)) {
346+ temp_scope = temp_scope->parent ;
347+ if (temp_scope->get_counter () != ASRUtils::symbol_parent_symtab (x.m_name )->get_counter ()) {
348+ function_dependencies.push_back (al, ASRUtils::symbol_name (x.m_name ));
349+ }
350+ } else {
351+ function_dependencies.push_back (al, ASRUtils::symbol_name (x.m_name ));
352+ }
347353 }
348354 }
349355
@@ -367,9 +373,15 @@ namespace LCompilers {
367373 SymbolTable* temp_scope = current_scope;
368374
369375 if (asr_owner_sym && temp_scope->get_counter () != ASRUtils::symbol_parent_symtab (x.m_name )->get_counter () &&
370- !ASR::is_a<ASR::AssociateBlock_t>(*asr_owner_sym) && !ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name ) &&
371- !ASR::is_a<ASR::Variable_t>(*x.m_name )) {
372- function_dependencies.push_back (al, ASRUtils::symbol_name (x.m_name ));
376+ !ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name ) && !ASR::is_a<ASR::Variable_t>(*x.m_name )) {
377+ if (ASR::is_a<ASR::AssociateBlock_t>(*asr_owner_sym) || ASR::is_a<ASR::Block_t>(*asr_owner_sym)) {
378+ temp_scope = temp_scope->parent ;
379+ if (temp_scope->get_counter () != ASRUtils::symbol_parent_symtab (x.m_name )->get_counter ()) {
380+ function_dependencies.push_back (al, ASRUtils::symbol_name (x.m_name ));
381+ }
382+ } else {
383+ function_dependencies.push_back (al, ASRUtils::symbol_name (x.m_name ));
384+ }
373385 }
374386 }
375387
@@ -384,10 +396,13 @@ namespace LCompilers {
384396 }
385397
386398 void visit_BlockCall (const ASR::BlockCall_t& x) {
399+ SymbolTable *parent_symtab = current_scope;
387400 ASR::Block_t* block = ASR::down_cast<ASR::Block_t>(x.m_m );
401+ current_scope = block->m_symtab ;
388402 for (size_t i=0 ; i<block->n_body ; i++) {
389403 visit_stmt (*(block->m_body [i]));
390404 }
405+ current_scope = parent_symtab;
391406 }
392407
393408 void visit_AssociateBlock (const ASR::AssociateBlock_t& x) {
0 commit comments