From 090ff05054756a1394712117515766bd96913e49 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 7 Jan 2017 14:24:08 -0500 Subject: [PATCH] add compile error for initializing struct with non struct type --- src/ir.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ir.cpp b/src/ir.cpp index 6304114b8..16467ff44 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -9578,6 +9578,13 @@ static TypeTableEntry *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstru TypeTableEntry *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields, bool depends_on_compile_var) { + if (container_type->id != TypeTableEntryIdStruct || is_slice(container_type)) { + ir_add_error(ira, instruction, + buf_sprintf("type '%s' does not support struct initialization syntax", + buf_ptr(&container_type->name))); + return ira->codegen->builtin_types.entry_invalid; + } + if (!type_is_complete(container_type)) resolve_container_type(ira->codegen, container_type);