Skip to content

Commit 15302e8

Browse files
committed
Adding workaround for when the user tries to unwrap 'type'
closes #1011
1 parent 1b3aaac commit 15302e8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/ir.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)