| ... | @@ -9985,8 +9985,23 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira, | ... | @@ -9985,8 +9985,23 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira, |
| 9985 | if (value->value.type->id == TypeTableEntryIdInvalid) | 9985 | if (value->value.type->id == TypeTableEntryIdInvalid) |
| 9986 | return ira->codegen->builtin_types.entry_invalid; | 9986 | return ira->codegen->builtin_types.entry_invalid; |
| 9987 | | 9987 | |
| 9988 | // This will be a pointer type because test null IR instruction operates on a pointer to a thing. | | |
| 9989 | TypeTableEntry *ptr_type = value->value.type; | 9988 | TypeTableEntry *ptr_type = value->value.type; |
| | 9989 | if (ptr_type->id == TypeTableEntryIdMetaType) { |
| | 9990 | // surprise! actually this is just ??T not an unwrap maybe instruction |
| | 9991 | TypeTableEntry *ptr_type_ptr = ir_resolve_type(ira, value); |
| | 9992 | assert(ptr_type_ptr->id == TypeTableEntryIdPointer); |
| | 9993 | TypeTableEntry *child_type = ptr_type_ptr->data.pointer.child_type; |
| | 9994 | type_ensure_zero_bits_known(ira->codegen, child_type); |
| | 9995 | TypeTableEntry *layer1 = get_maybe_type(ira->codegen, child_type); |
| | 9996 | TypeTableEntry *layer2 = get_maybe_type(ira->codegen, layer1); |
| | 9997 | TypeTableEntry *result_type = get_pointer_to_type(ira->codegen, layer2, true); |
| | 9998 | |
| | 9999 | IrInstruction *const_instr = ir_build_const_type(&ira->new_irb, unwrap_maybe_instruction->base.scope, |
| | 10000 | unwrap_maybe_instruction->base.source_node, result_type); |
| | 10001 | ir_link_new_instruction(const_instr, &unwrap_maybe_instruction->base); |
| | 10002 | return const_instr->value.type; |
| | 10003 | } |
| | 10004 | |
| 9990 | assert(ptr_type->id == TypeTableEntryIdPointer); | 10005 | assert(ptr_type->id == TypeTableEntryIdPointer); |
| 9991 | | 10006 | |
| 9992 | TypeTableEntry *type_entry = ptr_type->data.pointer.child_type; | 10007 | TypeTableEntry *type_entry = ptr_type->data.pointer.child_type; |