From 15302e84a45a04cfe94a8842318f02a608055962 Mon Sep 17 00:00:00 2001 From: Jimmi HC Date: Wed, 30 May 2018 11:51:46 +0200 Subject: [PATCH] Adding workaround for when the user tries to unwrap 'type' closes #1011 --- src/ir.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ir.cpp b/src/ir.cpp index 8d32a81e25..6e944a8976 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -17914,6 +17914,15 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, return ira->codegen->builtin_types.entry_invalid; TypeTableEntry *ptr_type = value->value.type; + // Because we don't have Pointer Reform yet, we can't have a pointer to a 'type'. + // Therefor, we have to check for type 'type' here, so we can output a correct error + // without asserting the assert below. + if (ptr_type->id == TypeTableEntryIdMetaType) { + ir_add_error(ira, value, + buf_sprintf("expected error union type, found '%s'", buf_ptr(&ptr_type->name))); + return ira->codegen->builtin_types.entry_invalid; + } + // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing. assert(ptr_type->id == TypeTableEntryIdPointer);