aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-01-07 14:24:08 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-01-07 14:24:08 -0500
commit090ff05054756a1394712117515766bd96913e49 (patch)
tree4832b9da9f26b4bb38db9bdb7f57392447ac50ec /src/ir.cpp
parentcf62f02ba99e45061f073f764d7d5a137ac35a67 (diff)
downloadzig-090ff05054756a1394712117515766bd96913e49.tar.gz
zig-090ff05054756a1394712117515766bd96913e49.zip
add compile error for initializing struct with non struct type
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 6304114b89..16467ff440 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);