authorgravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-05-30 11:51:46+02:00
committergravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-05-30 11:51:46+02:00
log15302e84a45a04cfe94a8842318f02a608055962
tree02e919ffd9a783abb5b984aaefd9c4b03f608e8b
parent1b3aaacba260e4c8d89ac98ab856ff9b3c77dac4

Adding workaround for when the user tries to unwrap 'type'

closes #1011

1 files changed, 9 insertions(+), 0 deletions(-)

src/ir.cpp+9
......@@ -17914,6 +17914,15 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira,
1791417914 return ira->codegen->builtin_types.entry_invalid;
1791517915 TypeTableEntry *ptr_type = value->value.type;
1791617916
17917 // Because we don't have Pointer Reform yet, we can't have a pointer to a 'type'.
17918 // Therefor, we have to check for type 'type' here, so we can output a correct error
17919 // without asserting the assert below.
17920 if (ptr_type->id == TypeTableEntryIdMetaType) {
17921 ir_add_error(ira, value,
17922 buf_sprintf("expected error union type, found '%s'", buf_ptr(&ptr_type->name)));
17923 return ira->codegen->builtin_types.entry_invalid;
17924 }
17925
1791717926 // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing.
1791817927 assert(ptr_type->id == TypeTableEntryIdPointer);
1791917928