diff options
| author | Jimmi HC <jhc@liab.dk> | 2018-05-30 11:51:46 +0200 |
|---|---|---|
| committer | Jimmi HC <jhc@liab.dk> | 2018-05-30 11:51:46 +0200 |
| commit | 15302e84a45a04cfe94a8842318f02a608055962 (patch) | |
| tree | 02e919ffd9a783abb5b984aaefd9c4b03f608e8b /src/ir.cpp | |
| parent | 1b3aaacba260e4c8d89ac98ab856ff9b3c77dac4 (diff) | |
| download | zig-15302e84a45a04cfe94a8842318f02a608055962.tar.gz zig-15302e84a45a04cfe94a8842318f02a608055962.zip | |
Adding workaround for when the user tries to unwrap 'type'
closes #1011
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
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); |
