Skip to content

Commit 2e48bca

Browse files
authored
Merge branch 'main' into bytes
2 parents 712b97f + 635ed20 commit 2e48bca

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

integration_tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ RUN(NAME test_import_04 LABELS cpython llvm llvm_jit c)
607607
RUN(NAME test_import_05 LABELS cpython llvm llvm_jit c wasm wasm_x86 wasm_x64)
608608
RUN(NAME test_import_06 LABELS cpython llvm llvm_jit)
609609
RUN(NAME test_import_07 LABELS cpython llvm llvm_jit c)
610+
RUN(NAME test_import_08 LABELS cpython llvm)
610611
RUN(NAME test_math LABELS cpython llvm llvm_jit NOFAST)
611612
RUN(NAME test_membership_01 LABELS cpython llvm)
612613
RUN(NAME test_numpy_01 LABELS cpython llvm llvm_jit c)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import string
2+
3+
import test_import_08_module
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from lpython import i32
2+
3+
a: i32 = 10
4+
b: i32 = a + 10
5+
6+
print("Inside import")

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4922,6 +4922,16 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
49224922
throw SemanticError("The module '" + mod_sym + "' cannot be loaded",
49234923
x.base.base.loc);
49244924
}
4925+
if( mod_sym == "__init__" ) {
4926+
for( auto item: ASRUtils::symbol_symtab(t)->get_scope() ) {
4927+
if( ASR::is_a<ASR::ExternalSymbol_t>(*item.second) ) {
4928+
current_module_dependencies.push_back(al,
4929+
ASR::down_cast<ASR::ExternalSymbol_t>(item.second)->m_module_name);
4930+
}
4931+
}
4932+
} else {
4933+
current_module_dependencies.push_back(al, s2c(al, mod_sym));
4934+
}
49254935
}
49264936
}
49274937

@@ -5126,6 +5136,7 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
51265136
tmp = nullptr;
51275137
tmp_vec.clear();
51285138
visit_stmt(*x.m_body[i]);
5139+
51295140
for (auto t: global_init) {
51305141
if (t) {
51315142
items.push_back(al, t);

0 commit comments

Comments
 (0)