@@ -441,15 +441,15 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
441441 verify_unique_dependencies (x.m_dependencies , x.n_dependencies ,
442442 x.m_name , x.base .base .loc );
443443
444- // Get the x symtab.
445- SymbolTable *x_symtab = x.m_symtab ;
444+ // Get the x parent symtab.
445+ SymbolTable *x_parent_symtab = x.m_symtab -> parent ;
446446
447447 // Dependencies of the function should be from function's parent symbol table.
448448 for ( size_t i = 0 ; i < x.n_dependencies ; i++ ) {
449449 std::string found_dep = x.m_dependencies [i];
450450
451451 // Get the symbol of the found_dep.
452- ASR::symbol_t * dep_sym = x_symtab ->resolve_symbol (found_dep);
452+ ASR::symbol_t * dep_sym = x_parent_symtab ->resolve_symbol (found_dep);
453453
454454 require (dep_sym != nullptr ,
455455 " Dependency " + found_dep + " is inside symbol table " + std::string (x.m_name ));
@@ -891,10 +891,16 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
891891
892892 SymbolTable* temp_scope = current_symtab;
893893
894- if (temp_scope->get_counter () != ASRUtils::symbol_parent_symtab (x.m_name )->get_counter () &&
895- !ASR::is_a<ASR::AssociateBlock_t>(*asr_owner_sym) && !ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name ) &&
896- !ASR::is_a<ASR::Variable_t>(*x.m_name )) {
897- function_dependencies.push_back (std::string (ASRUtils::symbol_name (x.m_name )));
894+ if (asr_owner_sym && temp_scope->get_counter () != ASRUtils::symbol_parent_symtab (x.m_name )->get_counter () &&
895+ !ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name ) && !ASR::is_a<ASR::Variable_t>(*x.m_name )) {
896+ if (ASR::is_a<ASR::AssociateBlock_t>(*asr_owner_sym) || ASR::is_a<ASR::Block_t>(*asr_owner_sym)) {
897+ temp_scope = temp_scope->parent ;
898+ if (temp_scope->get_counter () != ASRUtils::symbol_parent_symtab (x.m_name )->get_counter ()) {
899+ function_dependencies.push_back (std::string (ASRUtils::symbol_name (x.m_name )));
900+ }
901+ } else {
902+ function_dependencies.push_back (std::string (ASRUtils::symbol_name (x.m_name )));
903+ }
898904 }
899905
900906 if ( ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name ) ) {
@@ -1037,9 +1043,15 @@ class VerifyVisitor : public BaseWalkVisitor<VerifyVisitor>
10371043 SymbolTable* temp_scope = current_symtab;
10381044
10391045 if (asr_owner_sym && temp_scope->get_counter () != ASRUtils::symbol_parent_symtab (x.m_name )->get_counter () &&
1040- !ASR::is_a<ASR::AssociateBlock_t>(*asr_owner_sym) && !ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name ) &&
1041- !ASR::is_a<ASR::Variable_t>(*x.m_name )) {
1042- function_dependencies.push_back (std::string (ASRUtils::symbol_name (x.m_name )));
1046+ !ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name ) && !ASR::is_a<ASR::Variable_t>(*x.m_name )) {
1047+ if (ASR::is_a<ASR::AssociateBlock_t>(*asr_owner_sym) || ASR::is_a<ASR::Block_t>(*asr_owner_sym)) {
1048+ temp_scope = temp_scope->parent ;
1049+ if (temp_scope->get_counter () != ASRUtils::symbol_parent_symtab (x.m_name )->get_counter ()) {
1050+ function_dependencies.push_back (std::string (ASRUtils::symbol_name (x.m_name )));
1051+ }
1052+ } else {
1053+ function_dependencies.push_back (std::string (ASRUtils::symbol_name (x.m_name )));
1054+ }
10431055 }
10441056
10451057 if ( ASR::is_a<ASR::ExternalSymbol_t>(*x.m_name ) ) {
0 commit comments