| ... | @@ -9771,13 +9771,19 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node | ... | @@ -9771,13 +9771,19 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node |
| 9771 | return ir_exec_const_result(codegen, analyzed_executable); | 9771 | return ir_exec_const_result(codegen, analyzed_executable); |
| 9772 | } | 9772 | } |
| 9773 | | 9773 | |
| 9774 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { | 9774 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value, ZigTypeId wanted_type) { |
| 9775 | if (type_is_invalid(type_value->value.type)) | 9775 | if (type_is_invalid(type_value->value.type)) |
| 9776 | return ira->codegen->builtin_types.entry_invalid; | 9776 | return ira->codegen->builtin_types.entry_invalid; |
| 9777 | | 9777 | |
| | 9778 | const char *expected_type_str = type_id_name(ZigTypeIdMetaType); |
| | 9779 | |
| | 9780 | if (wanted_type != ZigTypeIdInvalid) { |
| | 9781 | expected_type_str = type_id_name(wanted_type); |
| | 9782 | } |
| | 9783 | |
| 9778 | if (type_value->value.type->id != ZigTypeIdMetaType) { | 9784 | if (type_value->value.type->id != ZigTypeIdMetaType) { |
| 9779 | ir_add_error(ira, type_value, | 9785 | ir_add_error( ira, type_value, |
| 9780 | buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value.type->name))); | 9786 | buf_sprintf("expected %s type, found '%s'", expected_type_str, buf_ptr(&type_value->value.type->name))); |
| 9781 | return ira->codegen->builtin_types.entry_invalid; | 9787 | return ira->codegen->builtin_types.entry_invalid; |
| 9782 | } | 9788 | } |
| 9783 | | 9789 | |
| ... | @@ -9786,7 +9792,16 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { | ... | @@ -9786,7 +9792,16 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { |
| 9786 | return ira->codegen->builtin_types.entry_invalid; | 9792 | return ira->codegen->builtin_types.entry_invalid; |
| 9787 | | 9793 | |
| 9788 | assert(const_val->data.x_type != nullptr); | 9794 | assert(const_val->data.x_type != nullptr); |
| 9789 | return const_val->data.x_type; | 9795 | |
| | 9796 | ZigType *out_type = const_val->data.x_type; |
| | 9797 | |
| | 9798 | if (wanted_type != ZigTypeIdInvalid && out_type->id != wanted_type) { |
| | 9799 | ir_add_error(ira, type_value, |
| | 9800 | buf_sprintf( "expected %s type, found '%s'", expected_type_str, buf_ptr(&out_type->name))); |
| | 9801 | return ira->codegen->builtin_types.entry_invalid; |
| | 9802 | } |
| | 9803 | |
| | 9804 | return out_type; |
| 9790 | } | 9805 | } |
| 9791 | | 9806 | |
| 9792 | static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { | 9807 | static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { |
| ... | @@ -10986,7 +11001,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10986,7 +11001,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10986 | } | 11001 | } |
| 10987 | | 11002 | |
| 10988 | ErrorMsg *parent_msg = ir_add_error_node(ira, source_instr->source_node, | 11003 | ErrorMsg *parent_msg = ir_add_error_node(ira, source_instr->source_node, |
| 10989 | buf_sprintf("expected type '%s', found '%s'", | 11004 | buf_sprintf("expected '%s' type, found '%s'", |
| 10990 | buf_ptr(&wanted_type->name), | 11005 | buf_ptr(&wanted_type->name), |
| 10991 | buf_ptr(&actual_type->name))); | 11006 | buf_ptr(&actual_type->name))); |
| 10992 | report_recursive_error(ira, source_instr->source_node, &const_cast_result, parent_msg); | 11007 | report_recursive_error(ira, source_instr->source_node, &const_cast_result, parent_msg); |
| ... | @@ -12214,7 +12229,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -12214,7 +12229,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 12214 | size_t op2_array_end; | 12229 | size_t op2_array_end; |
| 12215 | if (op2_type->id == ZigTypeIdArray) { | 12230 | if (op2_type->id == ZigTypeIdArray) { |
| 12216 | if (op2_type->data.array.child_type != child_type) { | 12231 | if (op2_type->data.array.child_type != child_type) { |
| 12217 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", | 12232 | ir_add_error(ira, op2, buf_sprintf("expected array of '%s' type, found '%s'", |
| 12218 | buf_ptr(&child_type->name), | 12233 | buf_ptr(&child_type->name), |
| 12219 | buf_ptr(&op2->value.type->name))); | 12234 | buf_ptr(&op2->value.type->name))); |
| 12220 | return ira->codegen->invalid_instruction; | 12235 | return ira->codegen->invalid_instruction; |
| ... | @@ -12228,7 +12243,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -12228,7 +12243,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 12228 | op2_val->data.x_ptr.data.base_array.is_cstr) | 12243 | op2_val->data.x_ptr.data.base_array.is_cstr) |
| 12229 | { | 12244 | { |
| 12230 | if (child_type != ira->codegen->builtin_types.entry_u8) { | 12245 | if (child_type != ira->codegen->builtin_types.entry_u8) { |
| 12231 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", | 12246 | ir_add_error(ira, op2, buf_sprintf("expected array of '%s' type, found '%s'", |
| 12232 | buf_ptr(&child_type->name), | 12247 | buf_ptr(&child_type->name), |
| 12233 | buf_ptr(&op2->value.type->name))); | 12248 | buf_ptr(&op2->value.type->name))); |
| 12234 | return ira->codegen->invalid_instruction; | 12249 | return ira->codegen->invalid_instruction; |
| ... | @@ -12239,7 +12254,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -12239,7 +12254,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 12239 | } else if (is_slice(op2_type)) { | 12254 | } else if (is_slice(op2_type)) { |
| 12240 | ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry; | 12255 | ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry; |
| 12241 | if (ptr_type->data.pointer.child_type != child_type) { | 12256 | if (ptr_type->data.pointer.child_type != child_type) { |
| 12242 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", | 12257 | ir_add_error(ira, op2, buf_sprintf("expected array of '%s' type, found '%s'", |
| 12243 | buf_ptr(&child_type->name), | 12258 | buf_ptr(&child_type->name), |
| 12244 | buf_ptr(&op2->value.type->name))); | 12259 | buf_ptr(&op2->value.type->name))); |
| 12245 | return ira->codegen->invalid_instruction; | 12260 | return ira->codegen->invalid_instruction; |
| ... | @@ -12253,7 +12268,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -12253,7 +12268,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 12253 | op2_array_end = bigint_as_unsigned(&len_val->data.x_bigint); | 12268 | op2_array_end = bigint_as_unsigned(&len_val->data.x_bigint); |
| 12254 | } else { | 12269 | } else { |
| 12255 | ir_add_error(ira, op2, | 12270 | ir_add_error(ira, op2, |
| 12256 | buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value.type->name))); | 12271 | buf_sprintf("expected array or C string literal type, found '%s'", buf_ptr(&op2->value.type->name))); |
| 12257 | return ira->codegen->invalid_instruction; | 12272 | return ira->codegen->invalid_instruction; |
| 12258 | } | 12273 | } |
| 12259 | | 12274 | |
| ... | @@ -12388,26 +12403,22 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -12388,26 +12403,22 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 12388 | } | 12403 | } |
| 12389 | | 12404 | |
| 12390 | static IrInstruction *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstructionBinOp *instruction) { | 12405 | static IrInstruction *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstructionBinOp *instruction) { |
| 12391 | ZigType *op1_type = ir_resolve_type(ira, instruction->op1->child); | 12406 | ZigType *op1_type = ir_resolve_type(ira, instruction->op1->child, ZigTypeIdErrorSet); |
| 12392 | if (type_is_invalid(op1_type)) | 12407 | if (type_is_invalid(op1_type)) { |
| 12393 | return ira->codegen->invalid_instruction; | 12408 | if (ira->codegen->errors.length != 0) { |
| 12394 | | 12409 | add_error_note( ira->codegen |
| 12395 | if (op1_type->id != ZigTypeIdErrorSet) { | 12410 | , ira->codegen->errors.last() |
| 12396 | ir_add_error(ira, instruction->op1, | 12411 | , instruction->base.source_node |
| 12397 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&op1_type->name))); | 12412 | , buf_sprintf("did you mean to use `or`?") |
| | 12413 | ); |
| | 12414 | } |
| 12398 | return ira->codegen->invalid_instruction; | 12415 | return ira->codegen->invalid_instruction; |
| 12399 | } | 12416 | } |
| 12400 | | 12417 | |
| 12401 | ZigType *op2_type = ir_resolve_type(ira, instruction->op2->child); | 12418 | ZigType *op2_type = ir_resolve_type(ira, instruction->op2->child, ZigTypeIdErrorSet); |
| 12402 | if (type_is_invalid(op2_type)) | 12419 | if (type_is_invalid(op2_type)) |
| 12403 | return ira->codegen->invalid_instruction; | 12420 | return ira->codegen->invalid_instruction; |
| 12404 | | 12421 | |
| 12405 | if (op2_type->id != ZigTypeIdErrorSet) { | | |
| 12406 | ir_add_error(ira, instruction->op2, | | |
| 12407 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&op2_type->name))); | | |
| 12408 | return ira->codegen->invalid_instruction; | | |
| 12409 | } | | |
| 12410 | | | |
| 12411 | if (type_is_global_error_set(op1_type) || | 12422 | if (type_is_global_error_set(op1_type) || |
| 12412 | type_is_global_error_set(op2_type)) | 12423 | type_is_global_error_set(op2_type)) |
| 12413 | { | 12424 | { |
| ... | @@ -12495,7 +12506,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruct | ... | @@ -12495,7 +12506,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruct |
| 12495 | IrInstruction *var_type = nullptr; | 12506 | IrInstruction *var_type = nullptr; |
| 12496 | if (decl_var_instruction->var_type != nullptr) { | 12507 | if (decl_var_instruction->var_type != nullptr) { |
| 12497 | var_type = decl_var_instruction->var_type->child; | 12508 | var_type = decl_var_instruction->var_type->child; |
| 12498 | ZigType *proposed_type = ir_resolve_type(ira, var_type); | 12509 | ZigType *proposed_type = ir_resolve_type(ira, var_type, ZigTypeIdInvalid); |
| 12499 | explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type); | 12510 | explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type); |
| 12500 | if (type_is_invalid(explicit_type)) { | 12511 | if (type_is_invalid(explicit_type)) { |
| 12501 | var->value->type = ira->codegen->builtin_types.entry_invalid; | 12512 | var->value->type = ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -12824,21 +12835,14 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, | ... | @@ -12824,21 +12835,14 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, |
| 12824 | { | 12835 | { |
| 12825 | Error err; | 12836 | Error err; |
| 12826 | | 12837 | |
| 12827 | ZigType *err_set_type = ir_resolve_type(ira, instruction->err_set->child); | 12838 | ZigType *err_set_type = ir_resolve_type(ira, instruction->err_set->child, ZigTypeIdErrorSet); |
| 12828 | if (type_is_invalid(err_set_type)) | 12839 | if (type_is_invalid(err_set_type)) |
| 12829 | return ira->codegen->invalid_instruction; | 12840 | return ira->codegen->invalid_instruction; |
| 12830 | | 12841 | |
| 12831 | ZigType *payload_type = ir_resolve_type(ira, instruction->payload->child); | 12842 | ZigType *payload_type = ir_resolve_type(ira, instruction->payload->child, ZigTypeIdInvalid); |
| 12832 | if (type_is_invalid(payload_type)) | 12843 | if (type_is_invalid(payload_type)) |
| 12833 | return ira->codegen->invalid_instruction; | 12844 | return ira->codegen->invalid_instruction; |
| 12834 | | 12845 | |
| 12835 | if (err_set_type->id != ZigTypeIdErrorSet) { | | |
| 12836 | ir_add_error(ira, instruction->err_set->child, | | |
| 12837 | buf_sprintf("expected error set type, found type '%s'", | | |
| 12838 | buf_ptr(&err_set_type->name))); | | |
| 12839 | return ira->codegen->invalid_instruction; | | |
| 12840 | } | | |
| 12841 | | | |
| 12842 | if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown))) | 12846 | if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown))) |
| 12843 | return ira->codegen->invalid_instruction; | 12847 | return ira->codegen->invalid_instruction; |
| 12844 | ZigType *result_type = get_error_union_type(ira->codegen, err_set_type, payload_type); | 12848 | ZigType *result_type = get_error_union_type(ira->codegen, err_set_type, payload_type); |
| ... | @@ -12900,7 +12904,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *c | ... | @@ -12900,7 +12904,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *c |
| 12900 | ZigType *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type; | 12904 | ZigType *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type; |
| 12901 | if (alloc_fn_type->id != ZigTypeIdFn) { | 12905 | if (alloc_fn_type->id != ZigTypeIdFn) { |
| 12902 | ir_add_error(ira, &call_instruction->base, | 12906 | ir_add_error(ira, &call_instruction->base, |
| 12903 | buf_sprintf("expected allocation function, found '%s'", buf_ptr(&alloc_fn_type->name))); | 12907 | buf_sprintf("expected allocation function type, found '%s'", buf_ptr(&alloc_fn_type->name))); |
| 12904 | return ira->codegen->invalid_instruction; | 12908 | return ira->codegen->invalid_instruction; |
| 12905 | } | 12909 | } |
| 12906 | | 12910 | |
| ... | @@ -13692,7 +13696,7 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC | ... | @@ -13692,7 +13696,7 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC |
| 13692 | | 13696 | |
| 13693 | if (is_comptime || instr_is_comptime(fn_ref)) { | 13697 | if (is_comptime || instr_is_comptime(fn_ref)) { |
| 13694 | if (fn_ref->value.type->id == ZigTypeIdMetaType) { | 13698 | if (fn_ref->value.type->id == ZigTypeIdMetaType) { |
| 13695 | ZigType *dest_type = ir_resolve_type(ira, fn_ref); | 13699 | ZigType *dest_type = ir_resolve_type(ira, fn_ref, ZigTypeIdInvalid); |
| 13696 | if (type_is_invalid(dest_type)) | 13700 | if (type_is_invalid(dest_type)) |
| 13697 | return ira->codegen->invalid_instruction; | 13701 | return ira->codegen->invalid_instruction; |
| 13698 | | 13702 | |
| ... | @@ -13817,7 +13821,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source | ... | @@ -13817,7 +13821,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source |
| 13817 | static IrInstruction *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) { | 13821 | static IrInstruction *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) { |
| 13818 | Error err; | 13822 | Error err; |
| 13819 | IrInstruction *value = un_op_instruction->value->child; | 13823 | IrInstruction *value = un_op_instruction->value->child; |
| 13820 | ZigType *type_entry = ir_resolve_type(ira, value); | 13824 | ZigType *type_entry = ir_resolve_type(ira, value, ZigTypeIdInvalid); |
| 13821 | if (type_is_invalid(type_entry)) | 13825 | if (type_is_invalid(type_entry)) |
| 13822 | return ira->codegen->invalid_instruction; | 13826 | return ira->codegen->invalid_instruction; |
| 13823 | if ((err = ensure_complete_type(ira->codegen, type_entry))) | 13827 | if ((err = ensure_complete_type(ira->codegen, type_entry))) |
| ... | @@ -15300,16 +15304,10 @@ static IrInstruction *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira, | ... | @@ -15300,16 +15304,10 @@ static IrInstruction *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira, |
| 15300 | IrInstructionPtrTypeChild *ptr_type_child_instruction) | 15304 | IrInstructionPtrTypeChild *ptr_type_child_instruction) |
| 15301 | { | 15305 | { |
| 15302 | IrInstruction *type_value = ptr_type_child_instruction->value->child; | 15306 | IrInstruction *type_value = ptr_type_child_instruction->value->child; |
| 15303 | ZigType *type_entry = ir_resolve_type(ira, type_value); | 15307 | ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdPointer); |
| 15304 | if (type_is_invalid(type_entry)) | 15308 | if (type_is_invalid(type_entry)) |
| 15305 | return ira->codegen->invalid_instruction; | 15309 | return ira->codegen->invalid_instruction; |
| 15306 | | 15310 | |
| 15307 | if (type_entry->id != ZigTypeIdPointer) { | | |
| 15308 | ir_add_error_node(ira, ptr_type_child_instruction->base.source_node, | | |
| 15309 | buf_sprintf("expected pointer type, found '%s'", buf_ptr(&type_entry->name))); | | |
| 15310 | return ira->codegen->invalid_instruction; | | |
| 15311 | } | | |
| 15312 | | | |
| 15313 | return ir_const_type(ira, &ptr_type_child_instruction->base, type_entry->data.pointer.child_type); | 15311 | return ir_const_type(ira, &ptr_type_child_instruction->base, type_entry->data.pointer.child_type); |
| 15314 | } | 15312 | } |
| 15315 | | 15313 | |
| ... | @@ -15462,7 +15460,7 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, | ... | @@ -15462,7 +15460,7 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 15462 | return ira->codegen->invalid_instruction; | 15460 | return ira->codegen->invalid_instruction; |
| 15463 | } | 15461 | } |
| 15464 | | 15462 | |
| 15465 | ZigType *child_type = ir_resolve_type(ira, slice_type_instruction->child_type->child); | 15463 | ZigType *child_type = ir_resolve_type(ira, slice_type_instruction->child_type->child, ZigTypeIdInvalid); |
| 15466 | if (type_is_invalid(child_type)) | 15464 | if (type_is_invalid(child_type)) |
| 15467 | return ira->codegen->invalid_instruction; | 15465 | return ira->codegen->invalid_instruction; |
| 15468 | | 15466 | |
| ... | @@ -15545,7 +15543,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs | ... | @@ -15545,7 +15543,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs |
| 15545 | AsmOutput *asm_output = asm_expr->output_list.at(i); | 15543 | AsmOutput *asm_output = asm_expr->output_list.at(i); |
| 15546 | if (asm_output->return_type) { | 15544 | if (asm_output->return_type) { |
| 15547 | output_types[i] = asm_instruction->output_types[i]->child; | 15545 | output_types[i] = asm_instruction->output_types[i]->child; |
| 15548 | return_type = ir_resolve_type(ira, output_types[i]); | 15546 | return_type = ir_resolve_type(ira, output_types[i], ZigTypeIdInvalid); |
| 15549 | if (type_is_invalid(return_type)) | 15547 | if (type_is_invalid(return_type)) |
| 15550 | return ira->codegen->invalid_instruction; | 15548 | return ira->codegen->invalid_instruction; |
| 15551 | } | 15549 | } |
| ... | @@ -15560,7 +15558,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs | ... | @@ -15560,7 +15558,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs |
| 15560 | (input_value->value.type->id == ZigTypeIdComptimeInt || | 15558 | (input_value->value.type->id == ZigTypeIdComptimeInt || |
| 15561 | input_value->value.type->id == ZigTypeIdComptimeFloat)) { | 15559 | input_value->value.type->id == ZigTypeIdComptimeFloat)) { |
| 15562 | ir_add_error_node(ira, input_value->source_node, | 15560 | ir_add_error_node(ira, input_value->source_node, |
| 15563 | buf_sprintf("expected sized integer or sized float, found %s", buf_ptr(&input_value->value.type->name))); | 15561 | buf_sprintf("expected sized integer or sized float type, found %s", buf_ptr(&input_value->value.type->name))); |
| 15564 | return ira->codegen->invalid_instruction; | 15562 | return ira->codegen->invalid_instruction; |
| 15565 | } | 15563 | } |
| 15566 | | 15564 | |
| ... | @@ -15586,7 +15584,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, | ... | @@ -15586,7 +15584,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 15586 | return ira->codegen->invalid_instruction; | 15584 | return ira->codegen->invalid_instruction; |
| 15587 | | 15585 | |
| 15588 | IrInstruction *child_type_value = array_type_instruction->child_type->child; | 15586 | IrInstruction *child_type_value = array_type_instruction->child_type->child; |
| 15589 | ZigType *child_type = ir_resolve_type(ira, child_type_value); | 15587 | ZigType *child_type = ir_resolve_type(ira, child_type_value, ZigTypeIdInvalid); |
| 15590 | if (type_is_invalid(child_type)) | 15588 | if (type_is_invalid(child_type)) |
| 15591 | return ira->codegen->invalid_instruction; | 15589 | return ira->codegen->invalid_instruction; |
| 15592 | switch (child_type->id) { | 15590 | switch (child_type->id) { |
| ... | @@ -15635,7 +15633,7 @@ static IrInstruction *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrInst | ... | @@ -15635,7 +15633,7 @@ static IrInstruction *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrInst |
| 15635 | if (instruction->payload_type == nullptr) { | 15633 | if (instruction->payload_type == nullptr) { |
| 15636 | promise_type = ira->codegen->builtin_types.entry_promise; | 15634 | promise_type = ira->codegen->builtin_types.entry_promise; |
| 15637 | } else { | 15635 | } else { |
| 15638 | ZigType *payload_type = ir_resolve_type(ira, instruction->payload_type->child); | 15636 | ZigType *payload_type = ir_resolve_type(ira, instruction->payload_type->child, ZigTypeIdInvalid); |
| 15639 | if (type_is_invalid(payload_type)) | 15637 | if (type_is_invalid(payload_type)) |
| 15640 | return ira->codegen->invalid_instruction; | 15638 | return ira->codegen->invalid_instruction; |
| 15641 | | 15639 | |
| ... | @@ -15650,7 +15648,7 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, | ... | @@ -15650,7 +15648,7 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, |
| 15650 | { | 15648 | { |
| 15651 | Error err; | 15649 | Error err; |
| 15652 | IrInstruction *type_value = size_of_instruction->type_value->child; | 15650 | IrInstruction *type_value = size_of_instruction->type_value->child; |
| 15653 | ZigType *type_entry = ir_resolve_type(ira, type_value); | 15651 | ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid); |
| 15654 | | 15652 | |
| 15655 | if ((err = ensure_complete_type(ira->codegen, type_entry))) | 15653 | if ((err = ensure_complete_type(ira->codegen, type_entry))) |
| 15656 | return ira->codegen->invalid_instruction; | 15654 | return ira->codegen->invalid_instruction; |
| ... | @@ -16485,7 +16483,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -16485,7 +16483,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 16485 | | 16483 | |
| 16486 | size_t elem_count = instruction->item_count; | 16484 | size_t elem_count = instruction->item_count; |
| 16487 | if (container_type_value->value.type->id == ZigTypeIdMetaType) { | 16485 | if (container_type_value->value.type->id == ZigTypeIdMetaType) { |
| 16488 | ZigType *container_type = ir_resolve_type(ira, container_type_value); | 16486 | ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid); |
| 16489 | if (type_is_invalid(container_type)) | 16487 | if (type_is_invalid(container_type)) |
| 16490 | return ira->codegen->invalid_instruction; | 16488 | return ira->codegen->invalid_instruction; |
| 16491 | | 16489 | |
| ... | @@ -16601,7 +16599,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -16601,7 +16599,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 16601 | | 16599 | |
| 16602 | static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, IrInstructionContainerInitFields *instruction) { | 16600 | static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, IrInstructionContainerInitFields *instruction) { |
| 16603 | IrInstruction *container_type_value = instruction->container_type->child; | 16601 | IrInstruction *container_type_value = instruction->container_type->child; |
| 16604 | ZigType *container_type = ir_resolve_type(ira, container_type_value); | 16602 | ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid); |
| 16605 | if (type_is_invalid(container_type)) | 16603 | if (type_is_invalid(container_type)) |
| 16606 | return ira->codegen->invalid_instruction; | 16604 | return ira->codegen->invalid_instruction; |
| 16607 | | 16605 | |
| ... | @@ -16719,7 +16717,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -16719,7 +16717,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 16719 | { | 16717 | { |
| 16720 | Error err; | 16718 | Error err; |
| 16721 | IrInstruction *type_value = instruction->type_value->child; | 16719 | IrInstruction *type_value = instruction->type_value->child; |
| 16722 | ZigType *container_type = ir_resolve_type(ira, type_value); | 16720 | ZigType *container_type = ir_resolve_type(ira, type_value, ZigTypeIdStruct); |
| 16723 | if (type_is_invalid(container_type)) | 16721 | if (type_is_invalid(container_type)) |
| 16724 | return ira->codegen->invalid_instruction; | 16722 | return ira->codegen->invalid_instruction; |
| 16725 | | 16723 | |
| ... | @@ -16732,12 +16730,6 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -16732,12 +16730,6 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 16732 | if (type_is_invalid(field_ptr->value.type)) | 16730 | if (type_is_invalid(field_ptr->value.type)) |
| 16733 | return ira->codegen->invalid_instruction; | 16731 | return ira->codegen->invalid_instruction; |
| 16734 | | 16732 | |
| 16735 | if (container_type->id != ZigTypeIdStruct) { | | |
| 16736 | ir_add_error(ira, type_value, | | |
| 16737 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); | | |
| 16738 | return ira->codegen->invalid_instruction; | | |
| 16739 | } | | |
| 16740 | | | |
| 16741 | if ((err = ensure_complete_type(ira->codegen, container_type))) | 16733 | if ((err = ensure_complete_type(ira->codegen, container_type))) |
| 16742 | return ira->codegen->invalid_instruction; | 16734 | return ira->codegen->invalid_instruction; |
| 16743 | | 16735 | |
| ... | @@ -16751,7 +16743,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -16751,7 +16743,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 16751 | | 16743 | |
| 16752 | if (field_ptr->value.type->id != ZigTypeIdPointer) { | 16744 | if (field_ptr->value.type->id != ZigTypeIdPointer) { |
| 16753 | ir_add_error(ira, field_ptr, | 16745 | ir_add_error(ira, field_ptr, |
| 16754 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value.type->name))); | 16746 | buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&field_ptr->value.type->name))); |
| 16755 | return ira->codegen->invalid_instruction; | 16747 | return ira->codegen->invalid_instruction; |
| 16756 | } | 16748 | } |
| 16757 | | 16749 | |
| ... | @@ -16810,9 +16802,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -16810,9 +16802,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 16810 | static TypeStructField *validate_byte_offset(IrAnalyze *ira, | 16802 | static TypeStructField *validate_byte_offset(IrAnalyze *ira, |
| 16811 | IrInstruction *type_value, | 16803 | IrInstruction *type_value, |
| 16812 | IrInstruction *field_name_value, | 16804 | IrInstruction *field_name_value, |
| 16813 | size_t *byte_offset) | 16805 | size_t *byte_offset) |
| 16814 | { | 16806 | { |
| 16815 | ZigType *container_type = ir_resolve_type(ira, type_value); | 16807 | ZigType *container_type = ir_resolve_type(ira, type_value, ZigTypeIdStruct); |
| 16816 | if (type_is_invalid(container_type)) | 16808 | if (type_is_invalid(container_type)) |
| 16817 | return nullptr; | 16809 | return nullptr; |
| 16818 | | 16810 | |
| ... | @@ -16824,12 +16816,6 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira, | ... | @@ -16824,12 +16816,6 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira, |
| 16824 | if (!field_name) | 16816 | if (!field_name) |
| 16825 | return nullptr; | 16817 | return nullptr; |
| 16826 | | 16818 | |
| 16827 | if (container_type->id != ZigTypeIdStruct) { | | |
| 16828 | ir_add_error(ira, type_value, | | |
| 16829 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); | | |
| 16830 | return nullptr; | | |
| 16831 | } | | |
| 16832 | | | |
| 16833 | TypeStructField *field = find_struct_type_field(container_type, field_name); | 16819 | TypeStructField *field = find_struct_type_field(container_type, field_name); |
| 16834 | if (field == nullptr) { | 16820 | if (field == nullptr) { |
| 16835 | ir_add_error(ira, field_name_value, | 16821 | ir_add_error(ira, field_name_value, |
| ... | @@ -17807,7 +17793,7 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, | ... | @@ -17807,7 +17793,7 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, |
| 17807 | { | 17793 | { |
| 17808 | Error err; | 17794 | Error err; |
| 17809 | IrInstruction *type_value = instruction->type_value->child; | 17795 | IrInstruction *type_value = instruction->type_value->child; |
| 17810 | ZigType *type_entry = ir_resolve_type(ira, type_value); | 17796 | ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid); |
| 17811 | if (type_is_invalid(type_entry)) | 17797 | if (type_is_invalid(type_entry)) |
| 17812 | return ira->codegen->invalid_instruction; | 17798 | return ira->codegen->invalid_instruction; |
| 17813 | | 17799 | |
| ... | @@ -17835,7 +17821,7 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira, | ... | @@ -17835,7 +17821,7 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira, |
| 17835 | IrInstructionTypeId *instruction) | 17821 | IrInstructionTypeId *instruction) |
| 17836 | { | 17822 | { |
| 17837 | IrInstruction *type_value = instruction->type_value->child; | 17823 | IrInstruction *type_value = instruction->type_value->child; |
| 17838 | ZigType *type_entry = ir_resolve_type(ira, type_value); | 17824 | ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid); |
| 17839 | if (type_is_invalid(type_entry)) | 17825 | if (type_is_invalid(type_entry)) |
| 17840 | return ira->codegen->invalid_instruction; | 17826 | return ira->codegen->invalid_instruction; |
| 17841 | | 17827 | |
| ... | @@ -17870,7 +17856,7 @@ static IrInstruction *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ir | ... | @@ -17870,7 +17856,7 @@ static IrInstruction *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ir |
| 17870 | | 17856 | |
| 17871 | static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) { | 17857 | static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) { |
| 17872 | IrInstruction *type_value = instruction->type_value->child; | 17858 | IrInstruction *type_value = instruction->type_value->child; |
| 17873 | ZigType *type_entry = ir_resolve_type(ira, type_value); | 17859 | ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid); |
| 17874 | if (type_is_invalid(type_entry)) | 17860 | if (type_is_invalid(type_entry)) |
| 17875 | return ira->codegen->invalid_instruction; | 17861 | return ira->codegen->invalid_instruction; |
| 17876 | | 17862 | |
| ... | @@ -18147,7 +18133,7 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction | ... | @@ -18147,7 +18133,7 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction |
| 18147 | | 18133 | |
| 18148 | static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) { | 18134 | static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) { |
| 18149 | IrInstruction *dest_type_value = instruction->dest_type->child; | 18135 | IrInstruction *dest_type_value = instruction->dest_type->child; |
| 18150 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); | 18136 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid); |
| 18151 | if (type_is_invalid(dest_type)) | 18137 | if (type_is_invalid(dest_type)) |
| 18152 | return ira->codegen->invalid_instruction; | 18138 | return ira->codegen->invalid_instruction; |
| 18153 | | 18139 | |
| ... | @@ -18200,7 +18186,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct | ... | @@ -18200,7 +18186,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct |
| 18200 | } | 18186 | } |
| 18201 | | 18187 | |
| 18202 | static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionIntCast *instruction) { | 18188 | static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionIntCast *instruction) { |
| 18203 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 18189 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid); |
| 18204 | if (type_is_invalid(dest_type)) | 18190 | if (type_is_invalid(dest_type)) |
| 18205 | return ira->codegen->invalid_instruction; | 18191 | return ira->codegen->invalid_instruction; |
| 18206 | | 18192 | |
| ... | @@ -18233,7 +18219,7 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct | ... | @@ -18233,7 +18219,7 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct |
| 18233 | } | 18219 | } |
| 18234 | | 18220 | |
| 18235 | static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionFloatCast *instruction) { | 18221 | static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionFloatCast *instruction) { |
| 18236 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 18222 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid); |
| 18237 | if (type_is_invalid(dest_type)) | 18223 | if (type_is_invalid(dest_type)) |
| 18238 | return ira->codegen->invalid_instruction; | 18224 | return ira->codegen->invalid_instruction; |
| 18239 | | 18225 | |
| ... | @@ -18273,16 +18259,10 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru | ... | @@ -18273,16 +18259,10 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru |
| 18273 | } | 18259 | } |
| 18274 | | 18260 | |
| 18275 | static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructionErrSetCast *instruction) { | 18261 | static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructionErrSetCast *instruction) { |
| 18276 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 18262 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdErrorSet); |
| 18277 | if (type_is_invalid(dest_type)) | 18263 | if (type_is_invalid(dest_type)) |
| 18278 | return ira->codegen->invalid_instruction; | 18264 | return ira->codegen->invalid_instruction; |
| 18279 | | 18265 | |
| 18280 | if (dest_type->id != ZigTypeIdErrorSet) { | | |
| 18281 | ir_add_error(ira, instruction->dest_type, | | |
| 18282 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&dest_type->name))); | | |
| 18283 | return ira->codegen->invalid_instruction; | | |
| 18284 | } | | |
| 18285 | | | |
| 18286 | IrInstruction *target = instruction->target->child; | 18266 | IrInstruction *target = instruction->target->child; |
| 18287 | if (type_is_invalid(target->value.type)) | 18267 | if (type_is_invalid(target->value.type)) |
| 18288 | return ira->codegen->invalid_instruction; | 18268 | return ira->codegen->invalid_instruction; |
| ... | @@ -18311,7 +18291,7 @@ static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_ali | ... | @@ -18311,7 +18291,7 @@ static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_ali |
| 18311 | static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) { | 18291 | static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) { |
| 18312 | Error err; | 18292 | Error err; |
| 18313 | | 18293 | |
| 18314 | ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->child); | 18294 | ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->child, ZigTypeIdInvalid); |
| 18315 | if (type_is_invalid(dest_child_type)) | 18295 | if (type_is_invalid(dest_child_type)) |
| 18316 | return ira->codegen->invalid_instruction; | 18296 | return ira->codegen->invalid_instruction; |
| 18317 | | 18297 | |
| ... | @@ -18408,7 +18388,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -18408,7 +18388,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 18408 | | 18388 | |
| 18409 | if (!is_slice(target->value.type)) { | 18389 | if (!is_slice(target->value.type)) { |
| 18410 | ir_add_error(ira, instruction->target, | 18390 | ir_add_error(ira, instruction->target, |
| 18411 | buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value.type->name))); | 18391 | buf_sprintf("expected slice type, found '%s'", buf_ptr(&target->value.type->name))); |
| 18412 | return ira->codegen->invalid_instruction; | 18392 | return ira->codegen->invalid_instruction; |
| 18413 | } | 18393 | } |
| 18414 | | 18394 | |
| ... | @@ -18427,7 +18407,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -18427,7 +18407,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 18427 | } | 18407 | } |
| 18428 | | 18408 | |
| 18429 | static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructionIntToFloat *instruction) { | 18409 | static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructionIntToFloat *instruction) { |
| 18430 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 18410 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid); |
| 18431 | if (type_is_invalid(dest_type)) | 18411 | if (type_is_invalid(dest_type)) |
| 18432 | return ira->codegen->invalid_instruction; | 18412 | return ira->codegen->invalid_instruction; |
| 18433 | | 18413 | |
| ... | @@ -18445,7 +18425,7 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst | ... | @@ -18445,7 +18425,7 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst |
| 18445 | } | 18425 | } |
| 18446 | | 18426 | |
| 18447 | static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) { | 18427 | static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) { |
| 18448 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 18428 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid); |
| 18449 | if (type_is_invalid(dest_type)) | 18429 | if (type_is_invalid(dest_type)) |
| 18450 | return ira->codegen->invalid_instruction; | 18430 | return ira->codegen->invalid_instruction; |
| 18451 | | 18431 | |
| ... | @@ -18501,7 +18481,7 @@ static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstr | ... | @@ -18501,7 +18481,7 @@ static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstr |
| 18501 | return ira->codegen->invalid_instruction; | 18481 | return ira->codegen->invalid_instruction; |
| 18502 | | 18482 | |
| 18503 | if (target->value.type->id != ZigTypeIdBool) { | 18483 | if (target->value.type->id != ZigTypeIdBool) { |
| 18504 | ir_add_error(ira, instruction->target, buf_sprintf("expected bool, found '%s'", | 18484 | ir_add_error(ira, instruction->target, buf_sprintf("expected bool type, found '%s'", |
| 18505 | buf_ptr(&target->value.type->name))); | 18485 | buf_ptr(&target->value.type->name))); |
| 18506 | return ira->codegen->invalid_instruction; | 18486 | return ira->codegen->invalid_instruction; |
| 18507 | } | 18487 | } |
| ... | @@ -19082,7 +19062,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst | ... | @@ -19082,7 +19062,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst |
| 19082 | IrInstruction *container = instruction->container->child; | 19062 | IrInstruction *container = instruction->container->child; |
| 19083 | if (type_is_invalid(container->value.type)) | 19063 | if (type_is_invalid(container->value.type)) |
| 19084 | return ira->codegen->invalid_instruction; | 19064 | return ira->codegen->invalid_instruction; |
| 19085 | ZigType *container_type = ir_resolve_type(ira, container); | 19065 | ZigType *container_type = ir_resolve_type(ira, container, ZigTypeIdInvalid); |
| 19086 | | 19066 | |
| 19087 | if ((err = ensure_complete_type(ira->codegen, container_type))) | 19067 | if ((err = ensure_complete_type(ira->codegen, container_type))) |
| 19088 | return ira->codegen->invalid_instruction; | 19068 | return ira->codegen->invalid_instruction; |
| ... | @@ -19116,7 +19096,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst | ... | @@ -19116,7 +19096,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst |
| 19116 | static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) { | 19096 | static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) { |
| 19117 | Error err; | 19097 | Error err; |
| 19118 | IrInstruction *container_type_value = instruction->container_type->child; | 19098 | IrInstruction *container_type_value = instruction->container_type->child; |
| 19119 | ZigType *container_type = ir_resolve_type(ira, container_type_value); | 19099 | ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid); |
| 19120 | if (type_is_invalid(container_type)) | 19100 | if (type_is_invalid(container_type)) |
| 19121 | return ira->codegen->invalid_instruction; | 19101 | return ira->codegen->invalid_instruction; |
| 19122 | | 19102 | |
| ... | @@ -19159,7 +19139,7 @@ static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstr | ... | @@ -19159,7 +19139,7 @@ static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstr |
| 19159 | static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) { | 19139 | static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) { |
| 19160 | Error err; | 19140 | Error err; |
| 19161 | IrInstruction *container_type_value = instruction->container_type->child; | 19141 | IrInstruction *container_type_value = instruction->container_type->child; |
| 19162 | ZigType *container_type = ir_resolve_type(ira, container_type_value); | 19142 | ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid); |
| 19163 | if (type_is_invalid(container_type)) | 19143 | if (type_is_invalid(container_type)) |
| 19164 | return ira->codegen->invalid_instruction; | 19144 | return ira->codegen->invalid_instruction; |
| 19165 | | 19145 | |
| ... | @@ -19252,7 +19232,7 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct | ... | @@ -19252,7 +19232,7 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct |
| 19252 | IrInstruction *type_value = instruction->type_value->child; | 19232 | IrInstruction *type_value = instruction->type_value->child; |
| 19253 | if (type_is_invalid(type_value->value.type)) | 19233 | if (type_is_invalid(type_value->value.type)) |
| 19254 | return ira->codegen->invalid_instruction; | 19234 | return ira->codegen->invalid_instruction; |
| 19255 | ZigType *type_entry = ir_resolve_type(ira, type_value); | 19235 | ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid); |
| 19256 | | 19236 | |
| 19257 | if ((err = type_resolve(ira->codegen, type_entry, ResolveStatusAlignmentKnown))) | 19237 | if ((err = type_resolve(ira->codegen, type_entry, ResolveStatusAlignmentKnown))) |
| 19258 | return ira->codegen->invalid_instruction; | 19238 | return ira->codegen->invalid_instruction; |
| ... | @@ -19302,16 +19282,10 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -19302,16 +19282,10 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 19302 | if (type_is_invalid(type_value->value.type)) | 19282 | if (type_is_invalid(type_value->value.type)) |
| 19303 | return ira->codegen->invalid_instruction; | 19283 | return ira->codegen->invalid_instruction; |
| 19304 | | 19284 | |
| 19305 | ZigType *dest_type = ir_resolve_type(ira, type_value); | 19285 | ZigType *dest_type = ir_resolve_type(ira, type_value, ZigTypeIdInt); |
| 19306 | if (type_is_invalid(dest_type)) | 19286 | if (type_is_invalid(dest_type)) |
| 19307 | return ira->codegen->invalid_instruction; | 19287 | return ira->codegen->invalid_instruction; |
| 19308 | | 19288 | |
| 19309 | if (dest_type->id != ZigTypeIdInt) { | | |
| 19310 | ir_add_error(ira, type_value, | | |
| 19311 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); | | |
| 19312 | return ira->codegen->invalid_instruction; | | |
| 19313 | } | | |
| 19314 | | | |
| 19315 | IrInstruction *op1 = instruction->op1->child; | 19289 | IrInstruction *op1 = instruction->op1->child; |
| 19316 | if (type_is_invalid(op1->value.type)) | 19290 | if (type_is_invalid(op1->value.type)) |
| 19317 | return ira->codegen->invalid_instruction; | 19291 | return ira->codegen->invalid_instruction; |
| ... | @@ -19581,7 +19555,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -19581,7 +19555,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 19581 | IrInstruction *param_type_value = instruction->param_types[fn_type_id.next_param_index]->child; | 19555 | IrInstruction *param_type_value = instruction->param_types[fn_type_id.next_param_index]->child; |
| 19582 | if (type_is_invalid(param_type_value->value.type)) | 19556 | if (type_is_invalid(param_type_value->value.type)) |
| 19583 | return ira->codegen->invalid_instruction; | 19557 | return ira->codegen->invalid_instruction; |
| 19584 | ZigType *param_type = ir_resolve_type(ira, param_type_value); | 19558 | ZigType *param_type = ir_resolve_type(ira, param_type_value, ZigTypeIdInvalid); |
| 19585 | switch (type_requires_comptime(ira->codegen, param_type)) { | 19559 | switch (type_requires_comptime(ira->codegen, param_type)) { |
| 19586 | case ReqCompTimeYes: | 19560 | case ReqCompTimeYes: |
| 19587 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { | 19561 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { |
| ... | @@ -19615,7 +19589,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -19615,7 +19589,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 19615 | } | 19589 | } |
| 19616 | | 19590 | |
| 19617 | IrInstruction *return_type_value = instruction->return_type->child; | 19591 | IrInstruction *return_type_value = instruction->return_type->child; |
| 19618 | fn_type_id.return_type = ir_resolve_type(ira, return_type_value); | 19592 | fn_type_id.return_type = ir_resolve_type(ira, return_type_value, ZigTypeIdInvalid); |
| 19619 | if (type_is_invalid(fn_type_id.return_type)) | 19593 | if (type_is_invalid(fn_type_id.return_type)) |
| 19620 | return ira->codegen->invalid_instruction; | 19594 | return ira->codegen->invalid_instruction; |
| 19621 | if (fn_type_id.return_type->id == ZigTypeIdOpaque) { | 19595 | if (fn_type_id.return_type->id == ZigTypeIdOpaque) { |
| ... | @@ -19631,7 +19605,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -19631,7 +19605,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 19631 | return ira->codegen->invalid_instruction; | 19605 | return ira->codegen->invalid_instruction; |
| 19632 | } | 19606 | } |
| 19633 | IrInstruction *async_allocator_type_value = instruction->async_allocator_type_value->child; | 19607 | IrInstruction *async_allocator_type_value = instruction->async_allocator_type_value->child; |
| 19634 | fn_type_id.async_allocator_type = ir_resolve_type(ira, async_allocator_type_value); | 19608 | fn_type_id.async_allocator_type = ir_resolve_type(ira, async_allocator_type_value, ZigTypeIdInvalid); |
| 19635 | if (type_is_invalid(fn_type_id.async_allocator_type)) | 19609 | if (type_is_invalid(fn_type_id.async_allocator_type)) |
| 19636 | return ira->codegen->invalid_instruction; | 19610 | return ira->codegen->invalid_instruction; |
| 19637 | } | 19611 | } |
| ... | @@ -19939,7 +19913,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -19939,7 +19913,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 19939 | result_type = get_slice_type(ira->codegen, result_ptr_type); | 19913 | result_type = get_slice_type(ira->codegen, result_ptr_type); |
| 19940 | } else { | 19914 | } else { |
| 19941 | ir_add_error(ira, target, | 19915 | ir_add_error(ira, target, |
| 19942 | buf_sprintf("expected pointer or slice, found '%s'", buf_ptr(&target_type->name))); | 19916 | buf_sprintf("expected pointer or slice type, found '%s'", buf_ptr(&target_type->name))); |
| 19943 | return ira->codegen->invalid_instruction; | 19917 | return ira->codegen->invalid_instruction; |
| 19944 | } | 19918 | } |
| 19945 | | 19919 | |
| ... | @@ -19985,13 +19959,13 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -19985,13 +19959,13 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 19985 | // validate src_type and dest_type. | 19959 | // validate src_type and dest_type. |
| 19986 | | 19960 | |
| 19987 | if (get_src_ptr_type(src_type) == nullptr) { | 19961 | if (get_src_ptr_type(src_type) == nullptr) { |
| 19988 | ir_add_error(ira, ptr, buf_sprintf("expected pointer, found '%s'", buf_ptr(&src_type->name))); | 19962 | ir_add_error(ira, ptr, buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&src_type->name))); |
| 19989 | return ira->codegen->invalid_instruction; | 19963 | return ira->codegen->invalid_instruction; |
| 19990 | } | 19964 | } |
| 19991 | | 19965 | |
| 19992 | if (get_src_ptr_type(dest_type) == nullptr) { | 19966 | if (get_src_ptr_type(dest_type) == nullptr) { |
| 19993 | ir_add_error(ira, dest_type_src, | 19967 | ir_add_error(ira, dest_type_src, |
| 19994 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name))); | 19968 | buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&dest_type->name))); |
| 19995 | return ira->codegen->invalid_instruction; | 19969 | return ira->codegen->invalid_instruction; |
| 19996 | } | 19970 | } |
| 19997 | | 19971 | |
| ... | @@ -20059,7 +20033,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -20059,7 +20033,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 20059 | | 20033 | |
| 20060 | static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCast *instruction) { | 20034 | static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCast *instruction) { |
| 20061 | IrInstruction *dest_type_value = instruction->dest_type->child; | 20035 | IrInstruction *dest_type_value = instruction->dest_type->child; |
| 20062 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); | 20036 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid); |
| 20063 | if (type_is_invalid(dest_type)) | 20037 | if (type_is_invalid(dest_type)) |
| 20064 | return ira->codegen->invalid_instruction; | 20038 | return ira->codegen->invalid_instruction; |
| 20065 | | 20039 | |
| ... | @@ -20255,7 +20229,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou | ... | @@ -20255,7 +20229,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 20255 | static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBitCast *instruction) { | 20229 | static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBitCast *instruction) { |
| 20256 | Error err; | 20230 | Error err; |
| 20257 | IrInstruction *dest_type_value = instruction->dest_type->child; | 20231 | IrInstruction *dest_type_value = instruction->dest_type->child; |
| 20258 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); | 20232 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid); |
| 20259 | if (type_is_invalid(dest_type)) | 20233 | if (type_is_invalid(dest_type)) |
| 20260 | return ira->codegen->invalid_instruction; | 20234 | return ira->codegen->invalid_instruction; |
| 20261 | | 20235 | |
| ... | @@ -20352,13 +20326,13 @@ static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruct | ... | @@ -20352,13 +20326,13 @@ static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruct |
| 20352 | static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) { | 20326 | static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) { |
| 20353 | Error err; | 20327 | Error err; |
| 20354 | IrInstruction *dest_type_value = instruction->dest_type->child; | 20328 | IrInstruction *dest_type_value = instruction->dest_type->child; |
| 20355 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); | 20329 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid); |
| 20356 | if (type_is_invalid(dest_type)) | 20330 | if (type_is_invalid(dest_type)) |
| 20357 | return ira->codegen->invalid_instruction; | 20331 | return ira->codegen->invalid_instruction; |
| 20358 | | 20332 | |
| 20359 | // We explicitly check for the size, so we can use get_src_ptr_type | 20333 | // We explicitly check for the size, so we can use get_src_ptr_type |
| 20360 | if (get_src_ptr_type(dest_type) == nullptr) { | 20334 | if (get_src_ptr_type(dest_type) == nullptr) { |
| 20361 | ir_add_error(ira, dest_type_value, buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name))); | 20335 | ir_add_error(ira, dest_type_value, buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&dest_type->name))); |
| 20362 | return ira->codegen->invalid_instruction; | 20336 | return ira->codegen->invalid_instruction; |
| 20363 | } | 20337 | } |
| 20364 | | 20338 | |
| ... | @@ -20461,7 +20435,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru | ... | @@ -20461,7 +20435,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru |
| 20461 | // We check size explicitly so we can use get_src_ptr_type here. | 20435 | // We check size explicitly so we can use get_src_ptr_type here. |
| 20462 | if (get_src_ptr_type(target->value.type) == nullptr) { | 20436 | if (get_src_ptr_type(target->value.type) == nullptr) { |
| 20463 | ir_add_error(ira, target, | 20437 | ir_add_error(ira, target, |
| 20464 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value.type->name))); | 20438 | buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&target->value.type->name))); |
| 20465 | return ira->codegen->invalid_instruction; | 20439 | return ira->codegen->invalid_instruction; |
| 20466 | } | 20440 | } |
| 20467 | | 20441 | |
| ... | @@ -20492,7 +20466,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru | ... | @@ -20492,7 +20466,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru |
| 20492 | | 20466 | |
| 20493 | static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) { | 20467 | static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) { |
| 20494 | Error err; | 20468 | Error err; |
| 20495 | ZigType *child_type = ir_resolve_type(ira, instruction->child_type->child); | 20469 | ZigType *child_type = ir_resolve_type(ira, instruction->child_type->child, ZigTypeIdInvalid); |
| 20496 | if (type_is_invalid(child_type)) | 20470 | if (type_is_invalid(child_type)) |
| 20497 | return ira->codegen->invalid_instruction; | 20471 | return ira->codegen->invalid_instruction; |
| 20498 | | 20472 | |
| ... | @@ -20591,7 +20565,7 @@ static IrInstruction *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrI | ... | @@ -20591,7 +20565,7 @@ static IrInstruction *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrI |
| 20591 | | 20565 | |
| 20592 | static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) { | 20566 | static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) { |
| 20593 | IrInstruction *fn_type_inst = instruction->fn_type->child; | 20567 | IrInstruction *fn_type_inst = instruction->fn_type->child; |
| 20594 | ZigType *fn_type = ir_resolve_type(ira, fn_type_inst); | 20568 | ZigType *fn_type = ir_resolve_type(ira, fn_type_inst, ZigTypeIdFn); |
| 20595 | if (type_is_invalid(fn_type)) | 20569 | if (type_is_invalid(fn_type)) |
| 20596 | return ira->codegen->invalid_instruction; | 20570 | return ira->codegen->invalid_instruction; |
| 20597 | | 20571 | |
| ... | @@ -20600,11 +20574,6 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct | ... | @@ -20600,11 +20574,6 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct |
| 20600 | if (!ir_resolve_usize(ira, arg_index_inst, &arg_index)) | 20574 | if (!ir_resolve_usize(ira, arg_index_inst, &arg_index)) |
| 20601 | return ira->codegen->invalid_instruction; | 20575 | return ira->codegen->invalid_instruction; |
| 20602 | | 20576 | |
| 20603 | if (fn_type->id != ZigTypeIdFn) { | | |
| 20604 | ir_add_error(ira, fn_type_inst, buf_sprintf("expected function, found '%s'", buf_ptr(&fn_type->name))); | | |
| 20605 | return ira->codegen->invalid_instruction; | | |
| 20606 | } | | |
| 20607 | | | |
| 20608 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; | 20577 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; |
| 20609 | if (arg_index >= fn_type_id->param_count) { | 20578 | if (arg_index >= fn_type_id->param_count) { |
| 20610 | ir_add_error(ira, arg_index_inst, | 20579 | ir_add_error(ira, arg_index_inst, |
| ... | @@ -20629,7 +20598,7 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct | ... | @@ -20629,7 +20598,7 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct |
| 20629 | static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) { | 20598 | static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) { |
| 20630 | Error err; | 20599 | Error err; |
| 20631 | IrInstruction *target_inst = instruction->target->child; | 20600 | IrInstruction *target_inst = instruction->target->child; |
| 20632 | ZigType *enum_type = ir_resolve_type(ira, target_inst); | 20601 | ZigType *enum_type = ir_resolve_type(ira, target_inst, ZigTypeIdInvalid); |
| 20633 | if (type_is_invalid(enum_type)) | 20602 | if (type_is_invalid(enum_type)) |
| 20634 | return ira->codegen->invalid_instruction; | 20603 | return ira->codegen->invalid_instruction; |
| 20635 | | 20604 | |
| ... | @@ -20654,7 +20623,7 @@ static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstruct | ... | @@ -20654,7 +20623,7 @@ static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstruct |
| 20654 | return ira->codegen->invalid_instruction; | 20623 | return ira->codegen->invalid_instruction; |
| 20655 | } | 20624 | } |
| 20656 | } else { | 20625 | } else { |
| 20657 | ir_add_error(ira, target_inst, buf_sprintf("expected enum or union, found '%s'", | 20626 | ir_add_error(ira, target_inst, buf_sprintf("expected enum or union type, found '%s'", |
| 20658 | buf_ptr(&enum_type->name))); | 20627 | buf_ptr(&enum_type->name))); |
| 20659 | return ira->codegen->invalid_instruction; | 20628 | return ira->codegen->invalid_instruction; |
| 20660 | } | 20629 | } |
| ... | @@ -20808,7 +20777,7 @@ static IrInstruction *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInst | ... | @@ -20808,7 +20777,7 @@ static IrInstruction *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInst |
| 20808 | if (coro_handle->value.type->id != ZigTypeIdPromise || | 20777 | if (coro_handle->value.type->id != ZigTypeIdPromise || |
| 20809 | coro_handle->value.type->data.promise.result_type == nullptr) | 20778 | coro_handle->value.type->data.promise.result_type == nullptr) |
| 20810 | { | 20779 | { |
| 20811 | ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T, found '%s'", | 20780 | ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T type, found '%s'", |
| 20812 | buf_ptr(&coro_handle->value.type->name))); | 20781 | buf_ptr(&coro_handle->value.type->name))); |
| 20813 | return ira->codegen->invalid_instruction; | 20782 | return ira->codegen->invalid_instruction; |
| 20814 | } | 20783 | } |
| ... | @@ -20839,7 +20808,7 @@ static IrInstruction *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira, I | ... | @@ -20839,7 +20808,7 @@ static IrInstruction *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira, I |
| 20839 | } | 20808 | } |
| 20840 | | 20809 | |
| 20841 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op) { | 20810 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op) { |
| 20842 | ZigType *operand_type = ir_resolve_type(ira, op); | 20811 | ZigType *operand_type = ir_resolve_type(ira, op, ZigTypeIdInvalid); |
| 20843 | if (type_is_invalid(operand_type)) | 20812 | if (type_is_invalid(operand_type)) |
| 20844 | return ira->codegen->builtin_types.entry_invalid; | 20813 | return ira->codegen->builtin_types.entry_invalid; |
| 20845 | | 20814 | |
| ... | @@ -20969,12 +20938,12 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr | ... | @@ -20969,12 +20938,12 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr |
| 20969 | } | 20938 | } |
| 20970 | | 20939 | |
| 20971 | static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, IrInstructionPromiseResultType *instruction) { | 20940 | static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, IrInstructionPromiseResultType *instruction) { |
| 20972 | ZigType *promise_type = ir_resolve_type(ira, instruction->promise_type->child); | 20941 | ZigType *promise_type = ir_resolve_type(ira, instruction->promise_type->child, ZigTypeIdInvalid); |
| 20973 | if (type_is_invalid(promise_type)) | 20942 | if (type_is_invalid(promise_type)) |
| 20974 | return ira->codegen->invalid_instruction; | 20943 | return ira->codegen->invalid_instruction; |
| 20975 | | 20944 | |
| 20976 | if (promise_type->id != ZigTypeIdPromise || promise_type->data.promise.result_type == nullptr) { | 20945 | if (promise_type->id != ZigTypeIdPromise || promise_type->data.promise.result_type == nullptr) { |
| 20977 | ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T, found '%s'", | 20946 | ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T type, found '%s'", |
| 20978 | buf_ptr(&promise_type->name))); | 20947 | buf_ptr(&promise_type->name))); |
| 20979 | return ira->codegen->invalid_instruction; | 20948 | return ira->codegen->invalid_instruction; |
| 20980 | } | 20949 | } |
| ... | @@ -20983,7 +20952,7 @@ static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, | ... | @@ -20983,7 +20952,7 @@ static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, |
| 20983 | } | 20952 | } |
| 20984 | | 20953 | |
| 20985 | static IrInstruction *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstructionAwaitBookkeeping *instruction) { | 20954 | static IrInstruction *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstructionAwaitBookkeeping *instruction) { |
| 20986 | ZigType *promise_result_type = ir_resolve_type(ira, instruction->promise_result_type->child); | 20955 | ZigType *promise_result_type = ir_resolve_type(ira, instruction->promise_result_type->child, ZigTypeIdInvalid); |
| 20987 | if (type_is_invalid(promise_result_type)) | 20956 | if (type_is_invalid(promise_result_type)) |
| 20988 | return ira->codegen->invalid_instruction; | 20957 | return ira->codegen->invalid_instruction; |
| 20989 | | 20958 | |
| ... | @@ -21046,7 +21015,7 @@ static IrInstruction *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *i | ... | @@ -21046,7 +21015,7 @@ static IrInstruction *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *i |
| 21046 | } | 21015 | } |
| 21047 | | 21016 | |
| 21048 | static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *instruction) { | 21017 | static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *instruction) { |
| 21049 | ZigType *float_type = ir_resolve_type(ira, instruction->type->child); | 21018 | ZigType *float_type = ir_resolve_type(ira, instruction->type->child, ZigTypeIdInvalid); |
| 21050 | if (type_is_invalid(float_type)) | 21019 | if (type_is_invalid(float_type)) |
| 21051 | return ira->codegen->invalid_instruction; | 21020 | return ira->codegen->invalid_instruction; |
| 21052 | | 21021 | |
| ... | @@ -21113,7 +21082,7 @@ static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionS | ... | @@ -21113,7 +21082,7 @@ static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionS |
| 21113 | } | 21082 | } |
| 21114 | | 21083 | |
| 21115 | static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstructionBswap *instruction) { | 21084 | static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstructionBswap *instruction) { |
| 21116 | ZigType *int_type = ir_resolve_type(ira, instruction->type->child); | 21085 | ZigType *int_type = ir_resolve_type(ira, instruction->type->child, ZigTypeIdInvalid); |
| 21117 | if (type_is_invalid(int_type)) | 21086 | if (type_is_invalid(int_type)) |
| 21118 | return ira->codegen->invalid_instruction; | 21087 | return ira->codegen->invalid_instruction; |
| 21119 | | 21088 | |
| ... | @@ -21169,7 +21138,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -21169,7 +21138,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 21169 | } | 21138 | } |
| 21170 | | 21139 | |
| 21171 | static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstructionBitReverse *instruction) { | 21140 | static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstructionBitReverse *instruction) { |
| 21172 | ZigType *int_type = ir_resolve_type(ira, instruction->type->child); | 21141 | ZigType *int_type = ir_resolve_type(ira, instruction->type->child, ZigTypeIdInvalid); |
| 21173 | if (type_is_invalid(int_type)) | 21142 | if (type_is_invalid(int_type)) |
| 21174 | return ira->codegen->invalid_instruction; | 21143 | return ira->codegen->invalid_instruction; |
| 21175 | | 21144 | |
| ... | @@ -21240,7 +21209,7 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr | ... | @@ -21240,7 +21209,7 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr |
| 21240 | | 21209 | |
| 21241 | if (target->value.type->id != ZigTypeIdEnum) { | 21210 | if (target->value.type->id != ZigTypeIdEnum) { |
| 21242 | ir_add_error(ira, instruction->target, | 21211 | ir_add_error(ira, instruction->target, |
| 21243 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value.type->name))); | 21212 | buf_sprintf("expected enum type, found '%s'", buf_ptr(&target->value.type->name))); |
| 21244 | return ira->codegen->invalid_instruction; | 21213 | return ira->codegen->invalid_instruction; |
| 21245 | } | 21214 | } |
| 21246 | | 21215 | |
| ... | @@ -21255,16 +21224,10 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr | ... | @@ -21255,16 +21224,10 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr |
| 21255 | static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) { | 21224 | static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) { |
| 21256 | Error err; | 21225 | Error err; |
| 21257 | IrInstruction *dest_type_value = instruction->dest_type->child; | 21226 | IrInstruction *dest_type_value = instruction->dest_type->child; |
| 21258 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); | 21227 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdEnum); |
| 21259 | if (type_is_invalid(dest_type)) | 21228 | if (type_is_invalid(dest_type)) |
| 21260 | return ira->codegen->invalid_instruction; | 21229 | return ira->codegen->invalid_instruction; |
| 21261 | | 21230 | |
| 21262 | if (dest_type->id != ZigTypeIdEnum) { | | |
| 21263 | ir_add_error(ira, instruction->dest_type, | | |
| 21264 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&dest_type->name))); | | |
| 21265 | return ira->codegen->invalid_instruction; | | |
| 21266 | } | | |
| 21267 | | | |
| 21268 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) | 21231 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) |
| 21269 | return ira->codegen->invalid_instruction; | 21232 | return ira->codegen->invalid_instruction; |
| 21270 | | 21233 | |