diff --git a/src/libasr/pass/instantiate_template.cpp b/src/libasr/pass/instantiate_template.cpp index 734e36d872..4bbe71daba 100644 --- a/src/libasr/pass/instantiate_template.cpp +++ b/src/libasr/pass/instantiate_template.cpp @@ -10,6 +10,7 @@ namespace LFortran { class FunctionInstantiator : public ASR::BaseExprStmtDuplicator { public: + SymbolTable *func_scope; SymbolTable *current_scope; std::map subs; std::map rt_subs; @@ -18,10 +19,10 @@ class FunctionInstantiator : public ASR::BaseExprStmtDuplicator dependencies; FunctionInstantiator(Allocator &al, std::map subs, - std::map rt_subs, SymbolTable *current_scope, + std::map rt_subs, SymbolTable *func_scope, std::string new_func_name): BaseExprStmtDuplicator(al), - current_scope{current_scope}, + func_scope{func_scope}, subs{subs}, rt_subs{rt_subs}, new_func_name{new_func_name} @@ -29,7 +30,6 @@ class FunctionInstantiator : public ASR::BaseExprStmtDuplicator(x->m_symtab->parent); Vec args; @@ -135,7 +135,6 @@ class FunctionInstantiator : public ASR::BaseExprStmtDuplicator(result); x->m_symtab->parent->add_symbol(new_func_name, t); - current_scope = parent_scope; return result; } @@ -223,7 +222,7 @@ class FunctionInstantiator : public ASR::BaseExprStmtDuplicatorm_name); - ASR::symbol_t *name = current_scope->get_symbol(sym_name); + ASR::symbol_t *name = func_scope->get_symbol(sym_name); Vec args; args.reserve(al, x->n_args); for (size_t i=0; in_args; i++) {