Skip to content

Commit 43ba941

Browse files
committed
Support importing unions
1 parent 4a87aab commit 43ba941

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,20 @@ ASR::symbol_t* import_from_module(Allocator &al, ASR::Module_t *m, SymbolTable *
483483
ASR::accessType::Public
484484
);
485485
return ASR::down_cast<ASR::symbol_t>(est);
486+
} else if (ASR::is_a<ASR::UnionType_t>(*t)) {
487+
ASR::UnionType_t *ut = ASR::down_cast<ASR::UnionType_t>(t);
488+
Str name;
489+
name.from_str(al, new_sym_name);
490+
char *cname = name.c_str(al);
491+
ASR::asr_t *est = ASR::make_ExternalSymbol_t(
492+
al, loc,
493+
/* a_symtab */ current_scope,
494+
/* a_name */ cname,
495+
(ASR::symbol_t*)ut,
496+
m->m_name, nullptr, 0, ut->m_name,
497+
ASR::accessType::Public
498+
);
499+
return ASR::down_cast<ASR::symbol_t>(est);
486500
} else if (ASR::is_a<ASR::Variable_t>(*t)) {
487501
ASR::Variable_t *mv = ASR::down_cast<ASR::Variable_t>(t);
488502
// `mv` is the Variable in a module. Now we construct

0 commit comments

Comments
 (0)