aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-05-21 09:50:15 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-05-21 09:50:15 -0400
commit1c6f415a6416f8b29897393b8adfef45e1a2b51f (patch)
treed9ee346ad26a726978f5025225476e6232ed8008 /src/ir.cpp
parent565ac3e27acedcd8dd2e39eff07de571bbcc3a1b (diff)
downloadzig-1c6f415a6416f8b29897393b8adfef45e1a2b51f.tar.gz
zig-1c6f415a6416f8b29897393b8adfef45e1a2b51f.zip
fix compiler crash when indexing types
closes #376
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index cc0e364487..0e089be1ed 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -9682,8 +9682,12 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
if (type_is_invalid(elem_index->value.type))
return ira->codegen->builtin_types.entry_invalid;
- // This will be a pointer type because elem ptr IR instruction operates on a pointer to a thing.
TypeTableEntry *ptr_type = array_ptr->value.type;
+ if (ptr_type->id == TypeTableEntryIdMetaType) {
+ ir_add_error(ira, &elem_ptr_instruction->base,
+ buf_sprintf("array access of non-array type '%s'", buf_ptr(&ptr_type->name)));
+ return ira->codegen->builtin_types.entry_invalid;
+ }
assert(ptr_type->id == TypeTableEntryIdPointer);
TypeTableEntry *array_type = ptr_type->data.pointer.child_type;