| ... | ... | @@ -11643,6 +11643,55 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru |
| 11643 | 11643 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 11644 | 11644 | return ira->codegen->builtin_types.entry_invalid; |
| 11645 | 11645 | } |
| 11646 | } else if (child_type->id == TypeTableEntryIdErrorUnion) { |
| 11647 | if (buf_eql_str(field_name, "Child")) { |
| 11648 | bool ptr_is_const = true; |
| 11649 | bool ptr_is_volatile = false; |
| 11650 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
| 11651 | create_const_type(ira->codegen, child_type->data.error.child_type), |
| 11652 | ira->codegen->builtin_types.entry_type, |
| 11653 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile); |
| 11654 | } else { |
| 11655 | ir_add_error(ira, &field_ptr_instruction->base, |
| 11656 | buf_sprintf("type '%s' has no member called '%s'", |
| 11657 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 11658 | return ira->codegen->builtin_types.entry_invalid; |
| 11659 | } |
| 11660 | } else if (child_type->id == TypeTableEntryIdMaybe) { |
| 11661 | if (buf_eql_str(field_name, "Child")) { |
| 11662 | bool ptr_is_const = true; |
| 11663 | bool ptr_is_volatile = false; |
| 11664 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
| 11665 | create_const_type(ira->codegen, child_type->data.maybe.child_type), |
| 11666 | ira->codegen->builtin_types.entry_type, |
| 11667 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile); |
| 11668 | } else { |
| 11669 | ir_add_error(ira, &field_ptr_instruction->base, |
| 11670 | buf_sprintf("type '%s' has no member called '%s'", |
| 11671 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 11672 | return ira->codegen->builtin_types.entry_invalid; |
| 11673 | } |
| 11674 | } else if (child_type->id == TypeTableEntryIdFn) { |
| 11675 | if (buf_eql_str(field_name, "ReturnType")) { |
| 11676 | bool ptr_is_const = true; |
| 11677 | bool ptr_is_volatile = false; |
| 11678 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
| 11679 | create_const_type(ira->codegen, child_type->data.fn.fn_type_id.return_type), |
| 11680 | ira->codegen->builtin_types.entry_type, |
| 11681 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile); |
| 11682 | } else if (buf_eql_str(field_name, "is_var_args")) { |
| 11683 | bool ptr_is_const = true; |
| 11684 | bool ptr_is_volatile = false; |
| 11685 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
| 11686 | create_const_bool(ira->codegen, child_type->data.fn.fn_type_id.is_var_args), |
| 11687 | ira->codegen->builtin_types.entry_bool, |
| 11688 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile); |
| 11689 | } else { |
| 11690 | ir_add_error(ira, &field_ptr_instruction->base, |
| 11691 | buf_sprintf("type '%s' has no member called '%s'", |
| 11692 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 11693 | return ira->codegen->builtin_types.entry_invalid; |
| 11694 | } |
| 11646 | 11695 | } else { |
| 11647 | 11696 | ir_add_error(ira, &field_ptr_instruction->base, |
| 11648 | 11697 | buf_sprintf("type '%s' does not support field access", buf_ptr(&child_type->name))); |