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
5 changes: 5 additions & 0 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2568,6 +2568,11 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
ASR::Variable_t* v_variable = ASR::down_cast<ASR::Variable_t>(v_sym);
std::string var_name = v_variable->m_name;
ASR::ttype_t* type = v_variable->m_type;
if (!init_expr && ASR::is_a<ASR::Dict_t>(*type)) {
init_expr = ASRUtils::EXPR(ASR::make_DictConstant_t(al, loc,
nullptr, 0, nullptr, 0, type));
}

if( init_expr ) {
value = ASRUtils::expr_value(init_expr);
SetChar variable_dependencies_vec;
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-dictionary1-a105a36.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-dictionary1-a105a36.stdout",
"stdout_hash": "3ea42309cc8f2201f43bb2fdeb28a85feea890fe49db4063af5c46f8",
"stdout_hash": "ac58817e3dc84de980d646cffeb63540c55bde9ca4229b8a7c58b77a",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
74 changes: 73 additions & 1 deletion tests/reference/asr-dictionary1-a105a36.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@
[]
[]
[(Assignment
(Var 3 x)
(DictConstant
[]
[]
(Dict
(Integer 4)
(Integer 4)
)
)
()
)
(Assignment
(Var 3 x)
(DictConstant
[(IntegerConstant 1 (Integer 4))
Expand All @@ -154,6 +166,18 @@
)
()
)
(Assignment
(Var 3 y)
(DictConstant
[]
[]
(Dict
(Character 1 -2 ())
(Integer 4)
)
)
()
)
(Assignment
(Var 3 y)
(DictConstant
Expand Down Expand Up @@ -286,6 +310,18 @@
[]
[]
[(Assignment
(Var 5 y)
(DictConstant
[]
[]
(Dict
(Character 1 -2 ())
(Integer 4)
)
)
()
)
(Assignment
(Var 5 y)
(DictConstant
[(StringConstant
Expand Down Expand Up @@ -390,6 +426,18 @@
[]
[]
[(Assignment
(Var 4 y)
(DictConstant
[]
[]
(Dict
(Character 1 -2 ())
(Integer 4)
)
)
()
)
(Assignment
(Var 4 y)
(DictConstant
[(StringConstant
Expand Down Expand Up @@ -494,6 +542,18 @@
[]
[]
[(Assignment
(Var 6 y)
(DictConstant
[]
[]
(Dict
(Character 1 -2 ())
(Integer 4)
)
)
()
)
(Assignment
(Var 6 y)
(DictConstant
[(StringConstant
Expand Down Expand Up @@ -574,7 +634,19 @@
)
[f]
[]
[(SubroutineCall
[(Assignment
(Var 8 x)
(DictConstant
[]
[]
(Dict
(Integer 4)
(Integer 4)
)
)
()
)
(SubroutineCall
2 f
()
[((Var 8 x))]
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-print_list_tuple_03-9de3736.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-print_list_tuple_03-9de3736.stdout",
"stdout_hash": "8962f3d49727ceb8f899acc2382f5fb6d24b16506a154ccf907400f5",
"stdout_hash": "9bc9712a40c386ddbd519614bb9ed900ebde24b5db7d0876f7e88e95",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
29 changes: 29 additions & 0 deletions tests/reference/asr-print_list_tuple_03-9de3736.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,21 @@
[]
[]
[(Assignment
(Var 3 x)
(DictConstant
[]
[]
(Dict
(Integer 4)
(Tuple
[(Integer 4)
(Integer 4)]
)
)
)
()
)
(Assignment
(Var 3 x)
(DictConstant
[(IntegerConstant 1 (Integer 4))
Expand Down Expand Up @@ -140,6 +155,20 @@
)
()
)
(Assignment
(Var 3 y)
(DictConstant
[]
[]
(Dict
(Integer 4)
(List
(Integer 4)
)
)
)
()
)
(Assignment
(Var 3 y)
(DictConstant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "pass_print_list_tuple-print_list_tuple_03-195fa9c.stdout",
"stdout_hash": "f63197ac9c1a649cfb2d3a3ef6f6672964ad753593afc68ce6d567e9",
"stdout_hash": "edb9d31c77ac27a72de4454275693936ef43c07263a2da687e16da5c",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@
[]
[]
[(Assignment
(Var 3 x)
(DictConstant
[]
[]
(Dict
(Integer 4)
(Tuple
[(Integer 4)
(Integer 4)]
)
)
)
()
)
(Assignment
(Var 3 x)
(DictConstant
[(IntegerConstant 1 (Integer 4))
Expand Down Expand Up @@ -174,6 +189,20 @@
)
()
)
(Assignment
(Var 3 y)
(DictConstant
[]
[]
(Dict
(Integer 4)
(List
(Integer 4)
)
)
)
()
)
(Assignment
(Var 3 y)
(DictConstant
Expand Down