Skip to content

Commit 20e5f74

Browse files
committed
fix: added initial implementation for supporting internal function defintions
1 parent b94d46d commit 20e5f74

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

integration_tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ RUN(NAME func_static_01 LABELS cpython llvm c wasm)
669669
RUN(NAME func_static_02 LABELS cpython llvm c wasm)
670670
RUN(NAME func_dep_03 LABELS cpython llvm c)
671671
RUN(NAME func_dep_04 LABELS cpython llvm c)
672+
RUN(NAME func_internal_def_01 LABELS cpython llvm c)
672673

673674
RUN(NAME float_01 LABELS cpython llvm c wasm wasm_x64)
674675
RUN(NAME recursive_01 LABELS cpython llvm c wasm wasm_x64 wasm_x86)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def main():
2+
x: i32
3+
x = (2+3)*5
4+
print(x)
5+
6+
def bar():
7+
print("bar")
8+
9+
bar()
10+
11+
main()

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,6 +4302,11 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
43024302
}
43034303
} else {
43044304
bool is_pure = false, is_module = false;
4305+
4306+
for (size_t i = 0; i < x.n_body; i++) {
4307+
visit_stmt(*x.m_body[i]);
4308+
}
4309+
43054310
tmp = ASRUtils::make_Function_t_util(
43064311
al, x.base.base.loc,
43074312
/* a_symtab */ current_scope,

0 commit comments

Comments
 (0)