Skip to content

Commit 312a72c

Browse files
committed
Handle a case of empty list where we need to type of ann_assign in make_call_helper
1 parent 2df121a commit 312a72c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,19 @@ class CommonVisitor : public AST::BaseVisitor<Derived> {
823823
return intrinsic_node_handler.get_intrinsic_node(call_name, al, loc,
824824
args);
825825
}
826+
827+
if (call_name == "list" && (args.size() == 0 || args[0].m_value == nullptr)) {
828+
if (ann_assign_target_type) {
829+
ASR::ttype_t *type = ASRUtils::get_contained_type(ann_assign_target_type);
830+
ASR::ttype_t* list_type = ASRUtils::TYPE(ASR::make_List_t(al, loc, type));
831+
Vec<ASR::expr_t*> list;
832+
list.reserve(al, 1);
833+
return ASR::make_ListConstant_t(al, loc, list.p,
834+
list.size(), list_type);
835+
}
836+
return nullptr;
837+
}
838+
826839
ASR::symbol_t *s_generic = nullptr, *stemp = s;
827840
// handling ExternalSymbol
828841
s = ASRUtils::symbol_get_past_external(s);

0 commit comments

Comments
 (0)