Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ RUN(NAME test_list_07 LABELS cpython llvm c)
RUN(NAME test_list_08 LABELS cpython llvm c)
RUN(NAME test_list_09 LABELS cpython llvm c)
RUN(NAME test_list_10 LABELS cpython llvm c)
RUN(NAME test_list_11 LABELS cpython llvm c)
RUN(NAME test_list_section LABELS cpython llvm c)
RUN(NAME test_list_count LABELS cpython llvm)
RUN(NAME test_list_index LABELS cpython llvm)
Expand Down
12 changes: 12 additions & 0 deletions integration_tests/test_list_11.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from lpython import i32

def return_empty_list_of_tuples() -> list[i32]:
return []

def main0():
x: list[i32] = return_empty_list_of_tuples()
print(len(x))

assert len(x) == 0

main0()
9 changes: 6 additions & 3 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6029,15 +6029,18 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
tmp = ASR::make_Return_t(al, x.base.base.loc);
return;
}
this->visit_expr(*x.m_value);
ASR::expr_t *value = ASRUtils::EXPR(tmp);
ASR::asr_t *return_var_ref = ASR::make_Var_t(al, x.base.base.loc, return_var);
ASR::expr_t *target = ASRUtils::EXPR(return_var_ref);
ASR::ttype_t *target_type = ASRUtils::expr_type(target);
ASR::ttype_t *value_type = ASRUtils::expr_type(value);
if( ASR::is_a<ASR::Const_t>(*target_type) ) {
target_type = ASRUtils::get_contained_type(target_type);
}
ASR::ttype_t* ann_assign_target_type_copy = ann_assign_target_type;
ann_assign_target_type = target_type;
this->visit_expr(*x.m_value);
ann_assign_target_type = ann_assign_target_type_copy;
ASR::expr_t *value = ASRUtils::EXPR(tmp);
ASR::ttype_t *value_type = ASRUtils::expr_type(value);
if( ASR::is_a<ASR::Const_t>(*value_type) ) {
value_type = ASRUtils::get_contained_type(value_type);
}
Expand Down