Skip to content

Commit a4f13a4

Browse files
Support global list import with a constant list as an initializer.
1 parent a49f18f commit a4f13a4

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/libasr/asr_scopes.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,21 @@ void SymbolTable::move_symbols_from_global_scope(Allocator &al,
202202
mod_dependencies.push_back(al, es->m_module_name);
203203
}
204204
es->m_parent_symtab = module_scope;
205+
ASR::symbol_t *s = ASRUtils::symbol_get_past_external(a.second);
206+
LCOMPILERS_ASSERT(s);
207+
if (ASR::is_a<ASR::Variable_t>(*s)) {
208+
ASR::Variable_t *v = ASR::down_cast<ASR::Variable_t>(s);
209+
if (v->m_symbolic_value && !ASR::is_a<ASR::Const_t>(*v->m_type)
210+
&& ASR::is_a<ASR::List_t>(*v->m_type)) {
211+
ASR::expr_t* target = ASRUtils::EXPR(ASR::make_Var_t(
212+
al, v->base.base.loc, (ASR::symbol_t *) es));
213+
ASR::expr_t *value = v->m_symbolic_value;
214+
215+
ASR::asr_t* assign = ASR::make_Assignment_t(al,
216+
v->base.base.loc, target, value, nullptr);
217+
var_init.push_back(al, ASRUtils::STMT(assign));
218+
}
219+
}
205220
module_scope->add_symbol(a.first, (ASR::symbol_t *) es);
206221
syms.push_back(al, s2c(al, a.first));
207222
break;
@@ -250,7 +265,7 @@ void SymbolTable::move_symbols_from_global_scope(Allocator &al,
250265
} default : {
251266
throw LCompilersException("Moving the symbol:`" + a.first +
252267
"` from global scope is not implemented yet");
253-
};
268+
}
254269
}
255270
}
256271
}

0 commit comments

Comments
 (0)