authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-07 14:24:08-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-07 14:24:08-05:00
log090ff05054756a1394712117515766bd96913e49
tree4832b9da9f26b4bb38db9bdb7f57392447ac50ec
parentcf62f02ba99e45061f073f764d7d5a137ac35a67

add compile error for initializing struct with non struct type


1 files changed, 7 insertions(+), 0 deletions(-)

src/ir.cpp+7
...@@ -9578,6 +9578,13 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru...@@ -9578,6 +9578,13 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru
9578 TypeTableEntry *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields,9578 TypeTableEntry *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields,
9579 bool depends_on_compile_var)9579 bool depends_on_compile_var)
9580{9580{
9581 if (container_type->id != TypeTableEntryIdStruct || is_slice(container_type)) {
9582 ir_add_error(ira, instruction,
9583 buf_sprintf("type '%s' does not support struct initialization syntax",
9584 buf_ptr(&container_type->name)));
9585 return ira->codegen->builtin_types.entry_invalid;
9586 }
9587
9581 if (!type_is_complete(container_type))9588 if (!type_is_complete(container_type))
9582 resolve_container_type(ira->codegen, container_type);9589 resolve_container_type(ira->codegen, container_type);
95839590