@@ -454,6 +454,22 @@ ASR::symbol_t* import_from_module(Allocator &al, ASR::Module_t *m, SymbolTable *
454
454
ASR::accessType::Public
455
455
);
456
456
return ASR::down_cast<ASR::symbol_t >(fn);
457
+ } else if (ASR::is_a<ASR::StructType_t>(*t)) {
458
+ ASR::StructType_t *st = ASR::down_cast<ASR::StructType_t>(t);
459
+ // `st` is the StructType in a module. Now we construct
460
+ // an ExternalSymbol that points to it.
461
+ Str name;
462
+ name.from_str (al, new_sym_name);
463
+ char *cname = name.c_str (al);
464
+ ASR::asr_t *est = ASR::make_ExternalSymbol_t (
465
+ al, st->base .base .loc ,
466
+ /* a_symtab */ current_scope,
467
+ /* a_name */ cname,
468
+ (ASR::symbol_t *)st,
469
+ m->m_name , nullptr , 0 , st->m_name ,
470
+ ASR::accessType::Public
471
+ );
472
+ return ASR::down_cast<ASR::symbol_t >(est);
457
473
} else if (ASR::is_a<ASR::Variable_t>(*t)) {
458
474
ASR::Variable_t *mv = ASR::down_cast<ASR::Variable_t>(t);
459
475
// `mv` is the Variable in a module. Now we construct
@@ -501,7 +517,7 @@ ASR::symbol_t* import_from_module(Allocator &al, ASR::Module_t *m, SymbolTable *
501
517
return import_from_module (al, mt, current_scope, std::string (mt->m_name ),
502
518
cur_sym_name, new_sym_name, loc);
503
519
} else {
504
- throw SemanticError (" Only Subroutines, Functions, Variables and "
520
+ throw SemanticError (" Only Subroutines, Functions, StructType, Variables and "
505
521
" ExternalSymbol are currently supported in 'import'" , loc);
506
522
}
507
523
LCOMPILERS_ASSERT (false );
0 commit comments