Skip to content

Commit c85d000

Browse files
committed
ASR: Error on missing struct initialization
1 parent b9850da commit c85d000

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,6 +2465,11 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
24652465
is_c_p_pointer_call = false;
24662466
if (x.m_value) {
24672467
this->visit_expr(*x.m_value);
2468+
} else {
2469+
if (ASR::is_a<ASR::Struct_t>(*type)) {
2470+
throw SemanticError(ASRUtils::type_to_str_python(type) + " " + var_name
2471+
+ " must be initialized a value", x.base.base.loc);
2472+
}
24682473
}
24692474
if( is_c_p_pointer_call ) {
24702475
create_add_variable_to_scope(var_name, nullptr, type,

0 commit comments

Comments
 (0)