authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-01-29 22:28:33-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-01-29 22:29:56-05:00
log9c328b42916d463465b134457c7f13b5c65da406
treea7c7a12ffcfe140c5912a09d742aa62180508536
parent5bf9ffdc5be02e67b57fe9398ad9d13147bfb0c8
signaturelock-open Commit is signed but in an unrecognized format.

simpler implementation of `&&` and `||` hints

This accomplishes the same goal, but with less changes, so that I can backport copy elision stuff easier.

6 files changed, 228 insertions(+), 212 deletions(-)

doc/langref.html.in+1-1
...@@ -6024,7 +6024,7 @@ fn add(a: i32, b: i32) i32 {...@@ -6024,7 +6024,7 @@ fn add(a: i32, b: i32) i32 {
6024 This is typically used for type safety when interacting with C code that does not expose struct details.6024 This is typically used for type safety when interacting with C code that does not expose struct details.
6025 Example:6025 Example:
6026 </p>6026 </p>
6027 {#code_begin|test_err|expected '*Derp' type, found '*Wat'#}6027 {#code_begin|test_err|expected type '*Derp', found '*Wat'#}
6028const Derp = @OpaqueType();6028const Derp = @OpaqueType();
6029const Wat = @OpaqueType();6029const Wat = @OpaqueType();
60306030
src/ir.cpp+144-91
...@@ -9771,19 +9771,13 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node...@@ -9771,19 +9771,13 @@ 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}
97739773
9774static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value, ZigTypeId wanted_type) {9774static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) {
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;
97779777
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
9784 if (type_value->value.type->id != ZigTypeIdMetaType) {9778 if (type_value->value.type->id != ZigTypeIdMetaType) {
9785 ir_add_error( ira, type_value,9779 ir_add_error(ira, type_value,
9786 buf_sprintf("expected %s type, found '%s'", expected_type_str, buf_ptr(&type_value->value.type->name)));9780 buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value.type->name)));
9787 return ira->codegen->builtin_types.entry_invalid;9781 return ira->codegen->builtin_types.entry_invalid;
9788 }9782 }
97899783
...@@ -9792,16 +9786,35 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value, ZigTy...@@ -9792,16 +9786,35 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value, ZigTy
9792 return ira->codegen->builtin_types.entry_invalid;9786 return ira->codegen->builtin_types.entry_invalid;
97939787
9794 assert(const_val->data.x_type != nullptr);9788 assert(const_val->data.x_type != nullptr);
9789 return const_val->data.x_type;
9790}
97959791
9796 ZigType *out_type = const_val->data.x_type;9792static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_source, IrInstruction *type_value) {
9793 if (type_is_invalid(type_value->value.type))
9794 return ira->codegen->builtin_types.entry_invalid;
97979795
9798 if (wanted_type != ZigTypeIdInvalid && out_type->id != wanted_type) {9796 if (type_value->value.type->id != ZigTypeIdMetaType) {
9799 ir_add_error(ira, type_value,9797 ErrorMsg *msg = ir_add_error(ira, type_value,
9800 buf_sprintf( "expected %s type, found '%s'", expected_type_str, buf_ptr(&out_type->name)));9798 buf_sprintf("expected error set type, found '%s'", buf_ptr(&type_value->value.type->name)));
9799 add_error_note(ira->codegen, msg, op_source->source_node,
9800 buf_sprintf("`||` merges error sets; `or` performs boolean OR"));
9801 return ira->codegen->builtin_types.entry_invalid;9801 return ira->codegen->builtin_types.entry_invalid;
9802 }9802 }
98039803
9804 return out_type;9804 ConstExprValue *const_val = ir_resolve_const(ira, type_value, UndefBad);
9805 if (!const_val)
9806 return ira->codegen->builtin_types.entry_invalid;
9807
9808 assert(const_val->data.x_type != nullptr);
9809 ZigType *result_type = const_val->data.x_type;
9810 if (result_type->id != ZigTypeIdErrorSet) {
9811 ErrorMsg *msg = ir_add_error(ira, type_value,
9812 buf_sprintf("expected error set type, found type '%s'", buf_ptr(&result_type->name)));
9813 add_error_note(ira->codegen, msg, op_source->source_node,
9814 buf_sprintf("`||` merges error sets; `or` performs boolean OR"));
9815 return ira->codegen->builtin_types.entry_invalid;
9816 }
9817 return result_type;
9805}9818}
98069819
9807static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) {9820static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) {
...@@ -11001,7 +11014,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -11001,7 +11014,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
11001 }11014 }
1100211015
11003 ErrorMsg *parent_msg = ir_add_error_node(ira, source_instr->source_node,11016 ErrorMsg *parent_msg = ir_add_error_node(ira, source_instr->source_node,
11004 buf_sprintf("expected '%s' type, found '%s'",11017 buf_sprintf("expected type '%s', found '%s'",
11005 buf_ptr(&wanted_type->name),11018 buf_ptr(&wanted_type->name),
11006 buf_ptr(&actual_type->name)));11019 buf_ptr(&actual_type->name)));
11007 report_recursive_error(ira, source_instr->source_node, &const_cast_result, parent_msg);11020 report_recursive_error(ira, source_instr->source_node, &const_cast_result, parent_msg);
...@@ -12229,7 +12242,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i...@@ -12229,7 +12242,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
12229 size_t op2_array_end;12242 size_t op2_array_end;
12230 if (op2_type->id == ZigTypeIdArray) {12243 if (op2_type->id == ZigTypeIdArray) {
12231 if (op2_type->data.array.child_type != child_type) {12244 if (op2_type->data.array.child_type != child_type) {
12232 ir_add_error(ira, op2, buf_sprintf("expected array of '%s' type, found '%s'",12245 ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'",
12233 buf_ptr(&child_type->name),12246 buf_ptr(&child_type->name),
12234 buf_ptr(&op2->value.type->name)));12247 buf_ptr(&op2->value.type->name)));
12235 return ira->codegen->invalid_instruction;12248 return ira->codegen->invalid_instruction;
...@@ -12243,7 +12256,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i...@@ -12243,7 +12256,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
12243 op2_val->data.x_ptr.data.base_array.is_cstr)12256 op2_val->data.x_ptr.data.base_array.is_cstr)
12244 {12257 {
12245 if (child_type != ira->codegen->builtin_types.entry_u8) {12258 if (child_type != ira->codegen->builtin_types.entry_u8) {
12246 ir_add_error(ira, op2, buf_sprintf("expected array of '%s' type, found '%s'",12259 ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'",
12247 buf_ptr(&child_type->name),12260 buf_ptr(&child_type->name),
12248 buf_ptr(&op2->value.type->name)));12261 buf_ptr(&op2->value.type->name)));
12249 return ira->codegen->invalid_instruction;12262 return ira->codegen->invalid_instruction;
...@@ -12254,7 +12267,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i...@@ -12254,7 +12267,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
12254 } else if (is_slice(op2_type)) {12267 } else if (is_slice(op2_type)) {
12255 ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry;12268 ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry;
12256 if (ptr_type->data.pointer.child_type != child_type) {12269 if (ptr_type->data.pointer.child_type != child_type) {
12257 ir_add_error(ira, op2, buf_sprintf("expected array of '%s' type, found '%s'",12270 ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'",
12258 buf_ptr(&child_type->name),12271 buf_ptr(&child_type->name),
12259 buf_ptr(&op2->value.type->name)));12272 buf_ptr(&op2->value.type->name)));
12260 return ira->codegen->invalid_instruction;12273 return ira->codegen->invalid_instruction;
...@@ -12268,7 +12281,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i...@@ -12268,7 +12281,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
12268 op2_array_end = bigint_as_unsigned(&len_val->data.x_bigint);12281 op2_array_end = bigint_as_unsigned(&len_val->data.x_bigint);
12269 } else {12282 } else {
12270 ir_add_error(ira, op2,12283 ir_add_error(ira, op2,
12271 buf_sprintf("expected array or C string literal type, found '%s'", buf_ptr(&op2->value.type->name)));12284 buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value.type->name)));
12272 return ira->codegen->invalid_instruction;12285 return ira->codegen->invalid_instruction;
12273 }12286 }
1227412287
...@@ -12403,19 +12416,11 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *...@@ -12403,19 +12416,11 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *
12403}12416}
1240412417
12405static IrInstruction *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstructionBinOp *instruction) {12418static IrInstruction *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstructionBinOp *instruction) {
12406 ZigType *op1_type = ir_resolve_type(ira, instruction->op1->child, ZigTypeIdErrorSet);12419 ZigType *op1_type = ir_resolve_error_set_type(ira, &instruction->base, instruction->op1->child);
12407 if (type_is_invalid(op1_type)) {12420 if (type_is_invalid(op1_type))
12408 if (ira->codegen->errors.length != 0) {
12409 add_error_note( ira->codegen
12410 , ira->codegen->errors.last()
12411 , instruction->base.source_node
12412 , buf_sprintf("did you mean to use `or`?")
12413 );
12414 }
12415 return ira->codegen->invalid_instruction;12421 return ira->codegen->invalid_instruction;
12416 }
1241712422
12418 ZigType *op2_type = ir_resolve_type(ira, instruction->op2->child, ZigTypeIdErrorSet);12423 ZigType *op2_type = ir_resolve_error_set_type(ira, &instruction->base, instruction->op2->child);
12419 if (type_is_invalid(op2_type))12424 if (type_is_invalid(op2_type))
12420 return ira->codegen->invalid_instruction;12425 return ira->codegen->invalid_instruction;
1242112426
...@@ -12506,7 +12511,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruct...@@ -12506,7 +12511,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruct
12506 IrInstruction *var_type = nullptr;12511 IrInstruction *var_type = nullptr;
12507 if (decl_var_instruction->var_type != nullptr) {12512 if (decl_var_instruction->var_type != nullptr) {
12508 var_type = decl_var_instruction->var_type->child;12513 var_type = decl_var_instruction->var_type->child;
12509 ZigType *proposed_type = ir_resolve_type(ira, var_type, ZigTypeIdInvalid);12514 ZigType *proposed_type = ir_resolve_type(ira, var_type);
12510 explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type);12515 explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type);
12511 if (type_is_invalid(explicit_type)) {12516 if (type_is_invalid(explicit_type)) {
12512 var->value->type = ira->codegen->builtin_types.entry_invalid;12517 var->value->type = ira->codegen->builtin_types.entry_invalid;
...@@ -12835,14 +12840,21 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira,...@@ -12835,14 +12840,21 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira,
12835{12840{
12836 Error err;12841 Error err;
1283712842
12838 ZigType *err_set_type = ir_resolve_type(ira, instruction->err_set->child, ZigTypeIdErrorSet);12843 ZigType *err_set_type = ir_resolve_type(ira, instruction->err_set->child);
12839 if (type_is_invalid(err_set_type))12844 if (type_is_invalid(err_set_type))
12840 return ira->codegen->invalid_instruction;12845 return ira->codegen->invalid_instruction;
1284112846
12842 ZigType *payload_type = ir_resolve_type(ira, instruction->payload->child, ZigTypeIdInvalid);12847 ZigType *payload_type = ir_resolve_type(ira, instruction->payload->child);
12843 if (type_is_invalid(payload_type))12848 if (type_is_invalid(payload_type))
12844 return ira->codegen->invalid_instruction;12849 return ira->codegen->invalid_instruction;
1284512850
12851 if (err_set_type->id != ZigTypeIdErrorSet) {
12852 ir_add_error(ira, instruction->err_set->child,
12853 buf_sprintf("expected error set type, found type '%s'",
12854 buf_ptr(&err_set_type->name)));
12855 return ira->codegen->invalid_instruction;
12856 }
12857
12846 if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown)))12858 if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown)))
12847 return ira->codegen->invalid_instruction;12859 return ira->codegen->invalid_instruction;
12848 ZigType *result_type = get_error_union_type(ira->codegen, err_set_type, payload_type);12860 ZigType *result_type = get_error_union_type(ira->codegen, err_set_type, payload_type);
...@@ -12904,7 +12916,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *c...@@ -12904,7 +12916,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *c
12904 ZigType *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type;12916 ZigType *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type;
12905 if (alloc_fn_type->id != ZigTypeIdFn) {12917 if (alloc_fn_type->id != ZigTypeIdFn) {
12906 ir_add_error(ira, &call_instruction->base,12918 ir_add_error(ira, &call_instruction->base,
12907 buf_sprintf("expected allocation function type, found '%s'", buf_ptr(&alloc_fn_type->name)));12919 buf_sprintf("expected allocation function, found '%s'", buf_ptr(&alloc_fn_type->name)));
12908 return ira->codegen->invalid_instruction;12920 return ira->codegen->invalid_instruction;
12909 }12921 }
1291012922
...@@ -13696,7 +13708,7 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC...@@ -13696,7 +13708,7 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC
1369613708
13697 if (is_comptime || instr_is_comptime(fn_ref)) {13709 if (is_comptime || instr_is_comptime(fn_ref)) {
13698 if (fn_ref->value.type->id == ZigTypeIdMetaType) {13710 if (fn_ref->value.type->id == ZigTypeIdMetaType) {
13699 ZigType *dest_type = ir_resolve_type(ira, fn_ref, ZigTypeIdInvalid);13711 ZigType *dest_type = ir_resolve_type(ira, fn_ref);
13700 if (type_is_invalid(dest_type))13712 if (type_is_invalid(dest_type))
13701 return ira->codegen->invalid_instruction;13713 return ira->codegen->invalid_instruction;
1370213714
...@@ -13821,7 +13833,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source...@@ -13821,7 +13833,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source
13821static IrInstruction *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {13833static IrInstruction *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
13822 Error err;13834 Error err;
13823 IrInstruction *value = un_op_instruction->value->child;13835 IrInstruction *value = un_op_instruction->value->child;
13824 ZigType *type_entry = ir_resolve_type(ira, value, ZigTypeIdInvalid);13836 ZigType *type_entry = ir_resolve_type(ira, value);
13825 if (type_is_invalid(type_entry))13837 if (type_is_invalid(type_entry))
13826 return ira->codegen->invalid_instruction;13838 return ira->codegen->invalid_instruction;
13827 if ((err = ensure_complete_type(ira->codegen, type_entry)))13839 if ((err = ensure_complete_type(ira->codegen, type_entry)))
...@@ -15304,10 +15316,16 @@ static IrInstruction *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira,...@@ -15304,10 +15316,16 @@ static IrInstruction *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira,
15304 IrInstructionPtrTypeChild *ptr_type_child_instruction)15316 IrInstructionPtrTypeChild *ptr_type_child_instruction)
15305{15317{
15306 IrInstruction *type_value = ptr_type_child_instruction->value->child;15318 IrInstruction *type_value = ptr_type_child_instruction->value->child;
15307 ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdPointer);15319 ZigType *type_entry = ir_resolve_type(ira, type_value);
15308 if (type_is_invalid(type_entry))15320 if (type_is_invalid(type_entry))
15309 return ira->codegen->invalid_instruction;15321 return ira->codegen->invalid_instruction;
1531015322
15323 if (type_entry->id != ZigTypeIdPointer) {
15324 ir_add_error_node(ira, ptr_type_child_instruction->base.source_node,
15325 buf_sprintf("expected pointer type, found '%s'", buf_ptr(&type_entry->name)));
15326 return ira->codegen->invalid_instruction;
15327 }
15328
15311 return ir_const_type(ira, &ptr_type_child_instruction->base, type_entry->data.pointer.child_type);15329 return ir_const_type(ira, &ptr_type_child_instruction->base, type_entry->data.pointer.child_type);
15312}15330}
1531315331
...@@ -15460,7 +15478,7 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira,...@@ -15460,7 +15478,7 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira,
15460 return ira->codegen->invalid_instruction;15478 return ira->codegen->invalid_instruction;
15461 }15479 }
1546215480
15463 ZigType *child_type = ir_resolve_type(ira, slice_type_instruction->child_type->child, ZigTypeIdInvalid);15481 ZigType *child_type = ir_resolve_type(ira, slice_type_instruction->child_type->child);
15464 if (type_is_invalid(child_type))15482 if (type_is_invalid(child_type))
15465 return ira->codegen->invalid_instruction;15483 return ira->codegen->invalid_instruction;
1546615484
...@@ -15543,7 +15561,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs...@@ -15543,7 +15561,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs
15543 AsmOutput *asm_output = asm_expr->output_list.at(i);15561 AsmOutput *asm_output = asm_expr->output_list.at(i);
15544 if (asm_output->return_type) {15562 if (asm_output->return_type) {
15545 output_types[i] = asm_instruction->output_types[i]->child;15563 output_types[i] = asm_instruction->output_types[i]->child;
15546 return_type = ir_resolve_type(ira, output_types[i], ZigTypeIdInvalid);15564 return_type = ir_resolve_type(ira, output_types[i]);
15547 if (type_is_invalid(return_type))15565 if (type_is_invalid(return_type))
15548 return ira->codegen->invalid_instruction;15566 return ira->codegen->invalid_instruction;
15549 }15567 }
...@@ -15558,7 +15576,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs...@@ -15558,7 +15576,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs
15558 (input_value->value.type->id == ZigTypeIdComptimeInt ||15576 (input_value->value.type->id == ZigTypeIdComptimeInt ||
15559 input_value->value.type->id == ZigTypeIdComptimeFloat)) {15577 input_value->value.type->id == ZigTypeIdComptimeFloat)) {
15560 ir_add_error_node(ira, input_value->source_node,15578 ir_add_error_node(ira, input_value->source_node,
15561 buf_sprintf("expected sized integer or sized float type, found %s", buf_ptr(&input_value->value.type->name)));15579 buf_sprintf("expected sized integer or sized float, found %s", buf_ptr(&input_value->value.type->name)));
15562 return ira->codegen->invalid_instruction;15580 return ira->codegen->invalid_instruction;
15563 }15581 }
1556415582
...@@ -15584,7 +15602,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira,...@@ -15584,7 +15602,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira,
15584 return ira->codegen->invalid_instruction;15602 return ira->codegen->invalid_instruction;
1558515603
15586 IrInstruction *child_type_value = array_type_instruction->child_type->child;15604 IrInstruction *child_type_value = array_type_instruction->child_type->child;
15587 ZigType *child_type = ir_resolve_type(ira, child_type_value, ZigTypeIdInvalid);15605 ZigType *child_type = ir_resolve_type(ira, child_type_value);
15588 if (type_is_invalid(child_type))15606 if (type_is_invalid(child_type))
15589 return ira->codegen->invalid_instruction;15607 return ira->codegen->invalid_instruction;
15590 switch (child_type->id) {15608 switch (child_type->id) {
...@@ -15633,7 +15651,7 @@ static IrInstruction *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrInst...@@ -15633,7 +15651,7 @@ static IrInstruction *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrInst
15633 if (instruction->payload_type == nullptr) {15651 if (instruction->payload_type == nullptr) {
15634 promise_type = ira->codegen->builtin_types.entry_promise;15652 promise_type = ira->codegen->builtin_types.entry_promise;
15635 } else {15653 } else {
15636 ZigType *payload_type = ir_resolve_type(ira, instruction->payload_type->child, ZigTypeIdInvalid);15654 ZigType *payload_type = ir_resolve_type(ira, instruction->payload_type->child);
15637 if (type_is_invalid(payload_type))15655 if (type_is_invalid(payload_type))
15638 return ira->codegen->invalid_instruction;15656 return ira->codegen->invalid_instruction;
1563915657
...@@ -15648,7 +15666,7 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira,...@@ -15648,7 +15666,7 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira,
15648{15666{
15649 Error err;15667 Error err;
15650 IrInstruction *type_value = size_of_instruction->type_value->child;15668 IrInstruction *type_value = size_of_instruction->type_value->child;
15651 ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid);15669 ZigType *type_entry = ir_resolve_type(ira, type_value);
1565215670
15653 if ((err = ensure_complete_type(ira->codegen, type_entry)))15671 if ((err = ensure_complete_type(ira->codegen, type_entry)))
15654 return ira->codegen->invalid_instruction;15672 return ira->codegen->invalid_instruction;
...@@ -16483,7 +16501,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,...@@ -16483,7 +16501,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
1648316501
16484 size_t elem_count = instruction->item_count;16502 size_t elem_count = instruction->item_count;
16485 if (container_type_value->value.type->id == ZigTypeIdMetaType) {16503 if (container_type_value->value.type->id == ZigTypeIdMetaType) {
16486 ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid);16504 ZigType *container_type = ir_resolve_type(ira, container_type_value);
16487 if (type_is_invalid(container_type))16505 if (type_is_invalid(container_type))
16488 return ira->codegen->invalid_instruction;16506 return ira->codegen->invalid_instruction;
1648916507
...@@ -16599,7 +16617,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,...@@ -16599,7 +16617,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
1659916617
16600static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, IrInstructionContainerInitFields *instruction) {16618static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, IrInstructionContainerInitFields *instruction) {
16601 IrInstruction *container_type_value = instruction->container_type->child;16619 IrInstruction *container_type_value = instruction->container_type->child;
16602 ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid);16620 ZigType *container_type = ir_resolve_type(ira, container_type_value);
16603 if (type_is_invalid(container_type))16621 if (type_is_invalid(container_type))
16604 return ira->codegen->invalid_instruction;16622 return ira->codegen->invalid_instruction;
1660516623
...@@ -16717,7 +16735,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,...@@ -16717,7 +16735,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
16717{16735{
16718 Error err;16736 Error err;
16719 IrInstruction *type_value = instruction->type_value->child;16737 IrInstruction *type_value = instruction->type_value->child;
16720 ZigType *container_type = ir_resolve_type(ira, type_value, ZigTypeIdStruct);16738 ZigType *container_type = ir_resolve_type(ira, type_value);
16721 if (type_is_invalid(container_type))16739 if (type_is_invalid(container_type))
16722 return ira->codegen->invalid_instruction;16740 return ira->codegen->invalid_instruction;
1672316741
...@@ -16730,6 +16748,12 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,...@@ -16730,6 +16748,12 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
16730 if (type_is_invalid(field_ptr->value.type))16748 if (type_is_invalid(field_ptr->value.type))
16731 return ira->codegen->invalid_instruction;16749 return ira->codegen->invalid_instruction;
1673216750
16751 if (container_type->id != ZigTypeIdStruct) {
16752 ir_add_error(ira, type_value,
16753 buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name)));
16754 return ira->codegen->invalid_instruction;
16755 }
16756
16733 if ((err = ensure_complete_type(ira->codegen, container_type)))16757 if ((err = ensure_complete_type(ira->codegen, container_type)))
16734 return ira->codegen->invalid_instruction;16758 return ira->codegen->invalid_instruction;
1673516759
...@@ -16743,7 +16767,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,...@@ -16743,7 +16767,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
1674316767
16744 if (field_ptr->value.type->id != ZigTypeIdPointer) {16768 if (field_ptr->value.type->id != ZigTypeIdPointer) {
16745 ir_add_error(ira, field_ptr,16769 ir_add_error(ira, field_ptr,
16746 buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&field_ptr->value.type->name)));16770 buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value.type->name)));
16747 return ira->codegen->invalid_instruction;16771 return ira->codegen->invalid_instruction;
16748 }16772 }
1674916773
...@@ -16802,9 +16826,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,...@@ -16802,9 +16826,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
16802static TypeStructField *validate_byte_offset(IrAnalyze *ira,16826static TypeStructField *validate_byte_offset(IrAnalyze *ira,
16803 IrInstruction *type_value,16827 IrInstruction *type_value,
16804 IrInstruction *field_name_value,16828 IrInstruction *field_name_value,
16805 size_t *byte_offset)16829 size_t *byte_offset)
16806{16830{
16807 ZigType *container_type = ir_resolve_type(ira, type_value, ZigTypeIdStruct);16831 ZigType *container_type = ir_resolve_type(ira, type_value);
16808 if (type_is_invalid(container_type))16832 if (type_is_invalid(container_type))
16809 return nullptr;16833 return nullptr;
1681016834
...@@ -16816,6 +16840,12 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira,...@@ -16816,6 +16840,12 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira,
16816 if (!field_name)16840 if (!field_name)
16817 return nullptr;16841 return nullptr;
1681816842
16843 if (container_type->id != ZigTypeIdStruct) {
16844 ir_add_error(ira, type_value,
16845 buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name)));
16846 return nullptr;
16847 }
16848
16819 TypeStructField *field = find_struct_type_field(container_type, field_name);16849 TypeStructField *field = find_struct_type_field(container_type, field_name);
16820 if (field == nullptr) {16850 if (field == nullptr) {
16821 ir_add_error(ira, field_name_value,16851 ir_add_error(ira, field_name_value,
...@@ -17793,7 +17823,7 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira,...@@ -17793,7 +17823,7 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira,
17793{17823{
17794 Error err;17824 Error err;
17795 IrInstruction *type_value = instruction->type_value->child;17825 IrInstruction *type_value = instruction->type_value->child;
17796 ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid);17826 ZigType *type_entry = ir_resolve_type(ira, type_value);
17797 if (type_is_invalid(type_entry))17827 if (type_is_invalid(type_entry))
17798 return ira->codegen->invalid_instruction;17828 return ira->codegen->invalid_instruction;
1779917829
...@@ -17821,7 +17851,7 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira,...@@ -17821,7 +17851,7 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira,
17821 IrInstructionTypeId *instruction)17851 IrInstructionTypeId *instruction)
17822{17852{
17823 IrInstruction *type_value = instruction->type_value->child;17853 IrInstruction *type_value = instruction->type_value->child;
17824 ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid);17854 ZigType *type_entry = ir_resolve_type(ira, type_value);
17825 if (type_is_invalid(type_entry))17855 if (type_is_invalid(type_entry))
17826 return ira->codegen->invalid_instruction;17856 return ira->codegen->invalid_instruction;
1782717857
...@@ -17856,7 +17886,7 @@ static IrInstruction *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ir...@@ -17856,7 +17886,7 @@ static IrInstruction *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ir
1785617886
17857static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) {17887static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) {
17858 IrInstruction *type_value = instruction->type_value->child;17888 IrInstruction *type_value = instruction->type_value->child;
17859 ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid);17889 ZigType *type_entry = ir_resolve_type(ira, type_value);
17860 if (type_is_invalid(type_entry))17890 if (type_is_invalid(type_entry))
17861 return ira->codegen->invalid_instruction;17891 return ira->codegen->invalid_instruction;
1786217892
...@@ -18133,7 +18163,7 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction...@@ -18133,7 +18163,7 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction
1813318163
18134static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) {18164static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) {
18135 IrInstruction *dest_type_value = instruction->dest_type->child;18165 IrInstruction *dest_type_value = instruction->dest_type->child;
18136 ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid);18166 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
18137 if (type_is_invalid(dest_type))18167 if (type_is_invalid(dest_type))
18138 return ira->codegen->invalid_instruction;18168 return ira->codegen->invalid_instruction;
1813918169
...@@ -18186,7 +18216,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct...@@ -18186,7 +18216,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct
18186}18216}
1818718217
18188static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionIntCast *instruction) {18218static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionIntCast *instruction) {
18189 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid);18219 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child);
18190 if (type_is_invalid(dest_type))18220 if (type_is_invalid(dest_type))
18191 return ira->codegen->invalid_instruction;18221 return ira->codegen->invalid_instruction;
1819218222
...@@ -18219,7 +18249,7 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct...@@ -18219,7 +18249,7 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct
18219}18249}
1822018250
18221static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionFloatCast *instruction) {18251static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionFloatCast *instruction) {
18222 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid);18252 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child);
18223 if (type_is_invalid(dest_type))18253 if (type_is_invalid(dest_type))
18224 return ira->codegen->invalid_instruction;18254 return ira->codegen->invalid_instruction;
1822518255
...@@ -18259,10 +18289,16 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru...@@ -18259,10 +18289,16 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru
18259}18289}
1826018290
18261static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructionErrSetCast *instruction) {18291static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructionErrSetCast *instruction) {
18262 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdErrorSet);18292 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child);
18263 if (type_is_invalid(dest_type))18293 if (type_is_invalid(dest_type))
18264 return ira->codegen->invalid_instruction;18294 return ira->codegen->invalid_instruction;
1826518295
18296 if (dest_type->id != ZigTypeIdErrorSet) {
18297 ir_add_error(ira, instruction->dest_type,
18298 buf_sprintf("expected error set type, found '%s'", buf_ptr(&dest_type->name)));
18299 return ira->codegen->invalid_instruction;
18300 }
18301
18266 IrInstruction *target = instruction->target->child;18302 IrInstruction *target = instruction->target->child;
18267 if (type_is_invalid(target->value.type))18303 if (type_is_invalid(target->value.type))
18268 return ira->codegen->invalid_instruction;18304 return ira->codegen->invalid_instruction;
...@@ -18291,7 +18327,7 @@ static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_ali...@@ -18291,7 +18327,7 @@ static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_ali
18291static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) {18327static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) {
18292 Error err;18328 Error err;
1829318329
18294 ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->child, ZigTypeIdInvalid);18330 ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->child);
18295 if (type_is_invalid(dest_child_type))18331 if (type_is_invalid(dest_child_type))
18296 return ira->codegen->invalid_instruction;18332 return ira->codegen->invalid_instruction;
1829718333
...@@ -18388,7 +18424,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct...@@ -18388,7 +18424,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct
1838818424
18389 if (!is_slice(target->value.type)) {18425 if (!is_slice(target->value.type)) {
18390 ir_add_error(ira, instruction->target,18426 ir_add_error(ira, instruction->target,
18391 buf_sprintf("expected slice type, found '%s'", buf_ptr(&target->value.type->name)));18427 buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value.type->name)));
18392 return ira->codegen->invalid_instruction;18428 return ira->codegen->invalid_instruction;
18393 }18429 }
1839418430
...@@ -18407,7 +18443,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct...@@ -18407,7 +18443,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct
18407}18443}
1840818444
18409static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructionIntToFloat *instruction) {18445static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructionIntToFloat *instruction) {
18410 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid);18446 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child);
18411 if (type_is_invalid(dest_type))18447 if (type_is_invalid(dest_type))
18412 return ira->codegen->invalid_instruction;18448 return ira->codegen->invalid_instruction;
1841318449
...@@ -18425,7 +18461,7 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst...@@ -18425,7 +18461,7 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst
18425}18461}
1842618462
18427static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) {18463static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) {
18428 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid);18464 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child);
18429 if (type_is_invalid(dest_type))18465 if (type_is_invalid(dest_type))
18430 return ira->codegen->invalid_instruction;18466 return ira->codegen->invalid_instruction;
1843118467
...@@ -18481,7 +18517,7 @@ static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstr...@@ -18481,7 +18517,7 @@ static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstr
18481 return ira->codegen->invalid_instruction;18517 return ira->codegen->invalid_instruction;
1848218518
18483 if (target->value.type->id != ZigTypeIdBool) {18519 if (target->value.type->id != ZigTypeIdBool) {
18484 ir_add_error(ira, instruction->target, buf_sprintf("expected bool type, found '%s'",18520 ir_add_error(ira, instruction->target, buf_sprintf("expected bool, found '%s'",
18485 buf_ptr(&target->value.type->name)));18521 buf_ptr(&target->value.type->name)));
18486 return ira->codegen->invalid_instruction;18522 return ira->codegen->invalid_instruction;
18487 }18523 }
...@@ -19062,7 +19098,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst...@@ -19062,7 +19098,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst
19062 IrInstruction *container = instruction->container->child;19098 IrInstruction *container = instruction->container->child;
19063 if (type_is_invalid(container->value.type))19099 if (type_is_invalid(container->value.type))
19064 return ira->codegen->invalid_instruction;19100 return ira->codegen->invalid_instruction;
19065 ZigType *container_type = ir_resolve_type(ira, container, ZigTypeIdInvalid);19101 ZigType *container_type = ir_resolve_type(ira, container);
1906619102
19067 if ((err = ensure_complete_type(ira->codegen, container_type)))19103 if ((err = ensure_complete_type(ira->codegen, container_type)))
19068 return ira->codegen->invalid_instruction;19104 return ira->codegen->invalid_instruction;
...@@ -19096,7 +19132,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst...@@ -19096,7 +19132,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst
19096static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) {19132static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) {
19097 Error err;19133 Error err;
19098 IrInstruction *container_type_value = instruction->container_type->child;19134 IrInstruction *container_type_value = instruction->container_type->child;
19099 ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid);19135 ZigType *container_type = ir_resolve_type(ira, container_type_value);
19100 if (type_is_invalid(container_type))19136 if (type_is_invalid(container_type))
19101 return ira->codegen->invalid_instruction;19137 return ira->codegen->invalid_instruction;
1910219138
...@@ -19139,7 +19175,7 @@ static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstr...@@ -19139,7 +19175,7 @@ static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstr
19139static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) {19175static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) {
19140 Error err;19176 Error err;
19141 IrInstruction *container_type_value = instruction->container_type->child;19177 IrInstruction *container_type_value = instruction->container_type->child;
19142 ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid);19178 ZigType *container_type = ir_resolve_type(ira, container_type_value);
19143 if (type_is_invalid(container_type))19179 if (type_is_invalid(container_type))
19144 return ira->codegen->invalid_instruction;19180 return ira->codegen->invalid_instruction;
1914519181
...@@ -19232,7 +19268,7 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct...@@ -19232,7 +19268,7 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct
19232 IrInstruction *type_value = instruction->type_value->child;19268 IrInstruction *type_value = instruction->type_value->child;
19233 if (type_is_invalid(type_value->value.type))19269 if (type_is_invalid(type_value->value.type))
19234 return ira->codegen->invalid_instruction;19270 return ira->codegen->invalid_instruction;
19235 ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid);19271 ZigType *type_entry = ir_resolve_type(ira, type_value);
1923619272
19237 if ((err = type_resolve(ira->codegen, type_entry, ResolveStatusAlignmentKnown)))19273 if ((err = type_resolve(ira->codegen, type_entry, ResolveStatusAlignmentKnown)))
19238 return ira->codegen->invalid_instruction;19274 return ira->codegen->invalid_instruction;
...@@ -19282,10 +19318,16 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr...@@ -19282,10 +19318,16 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
19282 if (type_is_invalid(type_value->value.type))19318 if (type_is_invalid(type_value->value.type))
19283 return ira->codegen->invalid_instruction;19319 return ira->codegen->invalid_instruction;
1928419320
19285 ZigType *dest_type = ir_resolve_type(ira, type_value, ZigTypeIdInt);19321 ZigType *dest_type = ir_resolve_type(ira, type_value);
19286 if (type_is_invalid(dest_type))19322 if (type_is_invalid(dest_type))
19287 return ira->codegen->invalid_instruction;19323 return ira->codegen->invalid_instruction;
1928819324
19325 if (dest_type->id != ZigTypeIdInt) {
19326 ir_add_error(ira, type_value,
19327 buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name)));
19328 return ira->codegen->invalid_instruction;
19329 }
19330
19289 IrInstruction *op1 = instruction->op1->child;19331 IrInstruction *op1 = instruction->op1->child;
19290 if (type_is_invalid(op1->value.type))19332 if (type_is_invalid(op1->value.type))
19291 return ira->codegen->invalid_instruction;19333 return ira->codegen->invalid_instruction;
...@@ -19555,7 +19597,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct...@@ -19555,7 +19597,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
19555 IrInstruction *param_type_value = instruction->param_types[fn_type_id.next_param_index]->child;19597 IrInstruction *param_type_value = instruction->param_types[fn_type_id.next_param_index]->child;
19556 if (type_is_invalid(param_type_value->value.type))19598 if (type_is_invalid(param_type_value->value.type))
19557 return ira->codegen->invalid_instruction;19599 return ira->codegen->invalid_instruction;
19558 ZigType *param_type = ir_resolve_type(ira, param_type_value, ZigTypeIdInvalid);19600 ZigType *param_type = ir_resolve_type(ira, param_type_value);
19559 switch (type_requires_comptime(ira->codegen, param_type)) {19601 switch (type_requires_comptime(ira->codegen, param_type)) {
19560 case ReqCompTimeYes:19602 case ReqCompTimeYes:
19561 if (!calling_convention_allows_zig_types(fn_type_id.cc)) {19603 if (!calling_convention_allows_zig_types(fn_type_id.cc)) {
...@@ -19589,7 +19631,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct...@@ -19589,7 +19631,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
19589 }19631 }
1959019632
19591 IrInstruction *return_type_value = instruction->return_type->child;19633 IrInstruction *return_type_value = instruction->return_type->child;
19592 fn_type_id.return_type = ir_resolve_type(ira, return_type_value, ZigTypeIdInvalid);19634 fn_type_id.return_type = ir_resolve_type(ira, return_type_value);
19593 if (type_is_invalid(fn_type_id.return_type))19635 if (type_is_invalid(fn_type_id.return_type))
19594 return ira->codegen->invalid_instruction;19636 return ira->codegen->invalid_instruction;
19595 if (fn_type_id.return_type->id == ZigTypeIdOpaque) {19637 if (fn_type_id.return_type->id == ZigTypeIdOpaque) {
...@@ -19605,7 +19647,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct...@@ -19605,7 +19647,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
19605 return ira->codegen->invalid_instruction;19647 return ira->codegen->invalid_instruction;
19606 }19648 }
19607 IrInstruction *async_allocator_type_value = instruction->async_allocator_type_value->child;19649 IrInstruction *async_allocator_type_value = instruction->async_allocator_type_value->child;
19608 fn_type_id.async_allocator_type = ir_resolve_type(ira, async_allocator_type_value, ZigTypeIdInvalid);19650 fn_type_id.async_allocator_type = ir_resolve_type(ira, async_allocator_type_value);
19609 if (type_is_invalid(fn_type_id.async_allocator_type))19651 if (type_is_invalid(fn_type_id.async_allocator_type))
19610 return ira->codegen->invalid_instruction;19652 return ira->codegen->invalid_instruction;
19611 }19653 }
...@@ -19913,7 +19955,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3...@@ -19913,7 +19955,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
19913 result_type = get_slice_type(ira->codegen, result_ptr_type);19955 result_type = get_slice_type(ira->codegen, result_ptr_type);
19914 } else {19956 } else {
19915 ir_add_error(ira, target,19957 ir_add_error(ira, target,
19916 buf_sprintf("expected pointer or slice type, found '%s'", buf_ptr(&target_type->name)));19958 buf_sprintf("expected pointer or slice, found '%s'", buf_ptr(&target_type->name)));
19917 return ira->codegen->invalid_instruction;19959 return ira->codegen->invalid_instruction;
19918 }19960 }
1991919961
...@@ -19959,13 +20001,13 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_...@@ -19959,13 +20001,13 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_
19959 // validate src_type and dest_type.20001 // validate src_type and dest_type.
1996020002
19961 if (get_src_ptr_type(src_type) == nullptr) {20003 if (get_src_ptr_type(src_type) == nullptr) {
19962 ir_add_error(ira, ptr, buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&src_type->name)));20004 ir_add_error(ira, ptr, buf_sprintf("expected pointer, found '%s'", buf_ptr(&src_type->name)));
19963 return ira->codegen->invalid_instruction;20005 return ira->codegen->invalid_instruction;
19964 }20006 }
1996520007
19966 if (get_src_ptr_type(dest_type) == nullptr) {20008 if (get_src_ptr_type(dest_type) == nullptr) {
19967 ir_add_error(ira, dest_type_src,20009 ir_add_error(ira, dest_type_src,
19968 buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&dest_type->name)));20010 buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name)));
19969 return ira->codegen->invalid_instruction;20011 return ira->codegen->invalid_instruction;
19970 }20012 }
1997120013
...@@ -20033,7 +20075,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_...@@ -20033,7 +20075,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_
2003320075
20034static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCast *instruction) {20076static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCast *instruction) {
20035 IrInstruction *dest_type_value = instruction->dest_type->child;20077 IrInstruction *dest_type_value = instruction->dest_type->child;
20036 ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid);20078 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
20037 if (type_is_invalid(dest_type))20079 if (type_is_invalid(dest_type))
20038 return ira->codegen->invalid_instruction;20080 return ira->codegen->invalid_instruction;
2003920081
...@@ -20229,7 +20271,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou...@@ -20229,7 +20271,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou
20229static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBitCast *instruction) {20271static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBitCast *instruction) {
20230 Error err;20272 Error err;
20231 IrInstruction *dest_type_value = instruction->dest_type->child;20273 IrInstruction *dest_type_value = instruction->dest_type->child;
20232 ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid);20274 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
20233 if (type_is_invalid(dest_type))20275 if (type_is_invalid(dest_type))
20234 return ira->codegen->invalid_instruction;20276 return ira->codegen->invalid_instruction;
2023520277
...@@ -20326,13 +20368,13 @@ static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruct...@@ -20326,13 +20368,13 @@ static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruct
20326static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) {20368static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) {
20327 Error err;20369 Error err;
20328 IrInstruction *dest_type_value = instruction->dest_type->child;20370 IrInstruction *dest_type_value = instruction->dest_type->child;
20329 ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid);20371 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
20330 if (type_is_invalid(dest_type))20372 if (type_is_invalid(dest_type))
20331 return ira->codegen->invalid_instruction;20373 return ira->codegen->invalid_instruction;
2033220374
20333 // We explicitly check for the size, so we can use get_src_ptr_type20375 // We explicitly check for the size, so we can use get_src_ptr_type
20334 if (get_src_ptr_type(dest_type) == nullptr) {20376 if (get_src_ptr_type(dest_type) == nullptr) {
20335 ir_add_error(ira, dest_type_value, buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&dest_type->name)));20377 ir_add_error(ira, dest_type_value, buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name)));
20336 return ira->codegen->invalid_instruction;20378 return ira->codegen->invalid_instruction;
20337 }20379 }
2033820380
...@@ -20435,7 +20477,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru...@@ -20435,7 +20477,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru
20435 // We check size explicitly so we can use get_src_ptr_type here.20477 // We check size explicitly so we can use get_src_ptr_type here.
20436 if (get_src_ptr_type(target->value.type) == nullptr) {20478 if (get_src_ptr_type(target->value.type) == nullptr) {
20437 ir_add_error(ira, target,20479 ir_add_error(ira, target,
20438 buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&target->value.type->name)));20480 buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value.type->name)));
20439 return ira->codegen->invalid_instruction;20481 return ira->codegen->invalid_instruction;
20440 }20482 }
2044120483
...@@ -20466,7 +20508,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru...@@ -20466,7 +20508,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru
2046620508
20467static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) {20509static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) {
20468 Error err;20510 Error err;
20469 ZigType *child_type = ir_resolve_type(ira, instruction->child_type->child, ZigTypeIdInvalid);20511 ZigType *child_type = ir_resolve_type(ira, instruction->child_type->child);
20470 if (type_is_invalid(child_type))20512 if (type_is_invalid(child_type))
20471 return ira->codegen->invalid_instruction;20513 return ira->codegen->invalid_instruction;
2047220514
...@@ -20565,7 +20607,7 @@ static IrInstruction *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrI...@@ -20565,7 +20607,7 @@ static IrInstruction *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrI
2056520607
20566static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) {20608static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) {
20567 IrInstruction *fn_type_inst = instruction->fn_type->child;20609 IrInstruction *fn_type_inst = instruction->fn_type->child;
20568 ZigType *fn_type = ir_resolve_type(ira, fn_type_inst, ZigTypeIdFn);20610 ZigType *fn_type = ir_resolve_type(ira, fn_type_inst);
20569 if (type_is_invalid(fn_type))20611 if (type_is_invalid(fn_type))
20570 return ira->codegen->invalid_instruction;20612 return ira->codegen->invalid_instruction;
2057120613
...@@ -20574,6 +20616,11 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct...@@ -20574,6 +20616,11 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct
20574 if (!ir_resolve_usize(ira, arg_index_inst, &arg_index))20616 if (!ir_resolve_usize(ira, arg_index_inst, &arg_index))
20575 return ira->codegen->invalid_instruction;20617 return ira->codegen->invalid_instruction;
2057620618
20619 if (fn_type->id != ZigTypeIdFn) {
20620 ir_add_error(ira, fn_type_inst, buf_sprintf("expected function, found '%s'", buf_ptr(&fn_type->name)));
20621 return ira->codegen->invalid_instruction;
20622 }
20623
20577 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;20624 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
20578 if (arg_index >= fn_type_id->param_count) {20625 if (arg_index >= fn_type_id->param_count) {
20579 ir_add_error(ira, arg_index_inst,20626 ir_add_error(ira, arg_index_inst,
...@@ -20598,7 +20645,7 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct...@@ -20598,7 +20645,7 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct
20598static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) {20645static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) {
20599 Error err;20646 Error err;
20600 IrInstruction *target_inst = instruction->target->child;20647 IrInstruction *target_inst = instruction->target->child;
20601 ZigType *enum_type = ir_resolve_type(ira, target_inst, ZigTypeIdInvalid);20648 ZigType *enum_type = ir_resolve_type(ira, target_inst);
20602 if (type_is_invalid(enum_type))20649 if (type_is_invalid(enum_type))
20603 return ira->codegen->invalid_instruction;20650 return ira->codegen->invalid_instruction;
2060420651
...@@ -20623,7 +20670,7 @@ static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstruct...@@ -20623,7 +20670,7 @@ static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstruct
20623 return ira->codegen->invalid_instruction;20670 return ira->codegen->invalid_instruction;
20624 }20671 }
20625 } else {20672 } else {
20626 ir_add_error(ira, target_inst, buf_sprintf("expected enum or union type, found '%s'",20673 ir_add_error(ira, target_inst, buf_sprintf("expected enum or union, found '%s'",
20627 buf_ptr(&enum_type->name)));20674 buf_ptr(&enum_type->name)));
20628 return ira->codegen->invalid_instruction;20675 return ira->codegen->invalid_instruction;
20629 }20676 }
...@@ -20777,7 +20824,7 @@ static IrInstruction *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInst...@@ -20777,7 +20824,7 @@ static IrInstruction *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInst
20777 if (coro_handle->value.type->id != ZigTypeIdPromise ||20824 if (coro_handle->value.type->id != ZigTypeIdPromise ||
20778 coro_handle->value.type->data.promise.result_type == nullptr)20825 coro_handle->value.type->data.promise.result_type == nullptr)
20779 {20826 {
20780 ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T type, found '%s'",20827 ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T, found '%s'",
20781 buf_ptr(&coro_handle->value.type->name)));20828 buf_ptr(&coro_handle->value.type->name)));
20782 return ira->codegen->invalid_instruction;20829 return ira->codegen->invalid_instruction;
20783 }20830 }
...@@ -20808,7 +20855,7 @@ static IrInstruction *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira, I...@@ -20808,7 +20855,7 @@ static IrInstruction *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira, I
20808}20855}
2080920856
20810static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op) {20857static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op) {
20811 ZigType *operand_type = ir_resolve_type(ira, op, ZigTypeIdInvalid);20858 ZigType *operand_type = ir_resolve_type(ira, op);
20812 if (type_is_invalid(operand_type))20859 if (type_is_invalid(operand_type))
20813 return ira->codegen->builtin_types.entry_invalid;20860 return ira->codegen->builtin_types.entry_invalid;
2081420861
...@@ -20938,12 +20985,12 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr...@@ -20938,12 +20985,12 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr
20938}20985}
2093920986
20940static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, IrInstructionPromiseResultType *instruction) {20987static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, IrInstructionPromiseResultType *instruction) {
20941 ZigType *promise_type = ir_resolve_type(ira, instruction->promise_type->child, ZigTypeIdInvalid);20988 ZigType *promise_type = ir_resolve_type(ira, instruction->promise_type->child);
20942 if (type_is_invalid(promise_type))20989 if (type_is_invalid(promise_type))
20943 return ira->codegen->invalid_instruction;20990 return ira->codegen->invalid_instruction;
2094420991
20945 if (promise_type->id != ZigTypeIdPromise || promise_type->data.promise.result_type == nullptr) {20992 if (promise_type->id != ZigTypeIdPromise || promise_type->data.promise.result_type == nullptr) {
20946 ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T type, found '%s'",20993 ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T, found '%s'",
20947 buf_ptr(&promise_type->name)));20994 buf_ptr(&promise_type->name)));
20948 return ira->codegen->invalid_instruction;20995 return ira->codegen->invalid_instruction;
20949 }20996 }
...@@ -20952,7 +20999,7 @@ static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira,...@@ -20952,7 +20999,7 @@ static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira,
20952}20999}
2095321000
20954static IrInstruction *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstructionAwaitBookkeeping *instruction) {21001static IrInstruction *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstructionAwaitBookkeeping *instruction) {
20955 ZigType *promise_result_type = ir_resolve_type(ira, instruction->promise_result_type->child, ZigTypeIdInvalid);21002 ZigType *promise_result_type = ir_resolve_type(ira, instruction->promise_result_type->child);
20956 if (type_is_invalid(promise_result_type))21003 if (type_is_invalid(promise_result_type))
20957 return ira->codegen->invalid_instruction;21004 return ira->codegen->invalid_instruction;
2095821005
...@@ -21015,7 +21062,7 @@ static IrInstruction *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *i...@@ -21015,7 +21062,7 @@ static IrInstruction *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *i
21015}21062}
2101621063
21017static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *instruction) {21064static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *instruction) {
21018 ZigType *float_type = ir_resolve_type(ira, instruction->type->child, ZigTypeIdInvalid);21065 ZigType *float_type = ir_resolve_type(ira, instruction->type->child);
21019 if (type_is_invalid(float_type))21066 if (type_is_invalid(float_type))
21020 return ira->codegen->invalid_instruction;21067 return ira->codegen->invalid_instruction;
2102121068
...@@ -21082,7 +21129,7 @@ static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionS...@@ -21082,7 +21129,7 @@ static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionS
21082}21129}
2108321130
21084static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstructionBswap *instruction) {21131static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstructionBswap *instruction) {
21085 ZigType *int_type = ir_resolve_type(ira, instruction->type->child, ZigTypeIdInvalid);21132 ZigType *int_type = ir_resolve_type(ira, instruction->type->child);
21086 if (type_is_invalid(int_type))21133 if (type_is_invalid(int_type))
21087 return ira->codegen->invalid_instruction;21134 return ira->codegen->invalid_instruction;
2108821135
...@@ -21138,7 +21185,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction...@@ -21138,7 +21185,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction
21138}21185}
2113921186
21140static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstructionBitReverse *instruction) {21187static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstructionBitReverse *instruction) {
21141 ZigType *int_type = ir_resolve_type(ira, instruction->type->child, ZigTypeIdInvalid);21188 ZigType *int_type = ir_resolve_type(ira, instruction->type->child);
21142 if (type_is_invalid(int_type))21189 if (type_is_invalid(int_type))
21143 return ira->codegen->invalid_instruction;21190 return ira->codegen->invalid_instruction;
2114421191
...@@ -21209,7 +21256,7 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr...@@ -21209,7 +21256,7 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr
2120921256
21210 if (target->value.type->id != ZigTypeIdEnum) {21257 if (target->value.type->id != ZigTypeIdEnum) {
21211 ir_add_error(ira, instruction->target,21258 ir_add_error(ira, instruction->target,
21212 buf_sprintf("expected enum type, found '%s'", buf_ptr(&target->value.type->name)));21259 buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value.type->name)));
21213 return ira->codegen->invalid_instruction;21260 return ira->codegen->invalid_instruction;
21214 }21261 }
2121521262
...@@ -21224,10 +21271,16 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr...@@ -21224,10 +21271,16 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr
21224static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) {21271static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) {
21225 Error err;21272 Error err;
21226 IrInstruction *dest_type_value = instruction->dest_type->child;21273 IrInstruction *dest_type_value = instruction->dest_type->child;
21227 ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdEnum);21274 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
21228 if (type_is_invalid(dest_type))21275 if (type_is_invalid(dest_type))
21229 return ira->codegen->invalid_instruction;21276 return ira->codegen->invalid_instruction;
2123021277
21278 if (dest_type->id != ZigTypeIdEnum) {
21279 ir_add_error(ira, instruction->dest_type,
21280 buf_sprintf("expected enum, found type '%s'", buf_ptr(&dest_type->name)));
21281 return ira->codegen->invalid_instruction;
21282 }
21283
21231 if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown)))21284 if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown)))
21232 return ira->codegen->invalid_instruction;21285 return ira->codegen->invalid_instruction;
2123321286
src/parser.cpp+6-29
...@@ -122,37 +122,19 @@ static AstNode *ast_parse_container_decl_type(ParseContext *pc);...@@ -122,37 +122,19 @@ static AstNode *ast_parse_container_decl_type(ParseContext *pc);
122static AstNode *ast_parse_byte_align(ParseContext *pc);122static AstNode *ast_parse_byte_align(ParseContext *pc);
123123
124ATTRIBUTE_PRINTF(3, 4)124ATTRIBUTE_PRINTF(3, 4)
125static ErrorMsg *ast_error(ParseContext *pc, Token *token, const char *format, ...) {
126 va_list ap;
127 va_start(ap, format);
128 Buf *msg = buf_vprintf(format, ap);
129 va_end(ap);
130
131 ErrorMsg *err = err_msg_create_with_line(pc->owner->path, token->start_line, token->start_column,
132 pc->owner->source_code, pc->owner->line_offsets, msg);
133 err->line_start = token->start_line;
134 err->column_start = token->start_column;
135
136 return err;
137}
138
139ATTRIBUTE_PRINTF(4, 5)
140ATTRIBUTE_NORETURN125ATTRIBUTE_NORETURN
141static void ast_error_exit(ParseContext *pc, Token *token, ErrorMsg *note, const char *format, ...) {126static void ast_error(ParseContext *pc, Token *token, const char *format, ...) {
142 va_list ap;127 va_list ap;
143 va_start(ap, format);128 va_start(ap, format);
144 Buf *msg = buf_vprintf(format, ap);129 Buf *msg = buf_vprintf(format, ap);
145 va_end(ap);130 va_end(ap);
146131
132
147 ErrorMsg *err = err_msg_create_with_line(pc->owner->path, token->start_line, token->start_column,133 ErrorMsg *err = err_msg_create_with_line(pc->owner->path, token->start_line, token->start_column,
148 pc->owner->source_code, pc->owner->line_offsets, msg);134 pc->owner->source_code, pc->owner->line_offsets, msg);
149 err->line_start = token->start_line;135 err->line_start = token->start_line;
150 err->column_start = token->start_column;136 err->column_start = token->start_column;
151137
152 if (note) {
153 err->notes.append(note);
154 }
155
156 print_err_msg(err, pc->err_color);138 print_err_msg(err, pc->err_color);
157 exit(EXIT_FAILURE);139 exit(EXIT_FAILURE);
158}140}
...@@ -182,7 +164,7 @@ static Buf ast_token_str(Buf *input, Token *token) {...@@ -182,7 +164,7 @@ static Buf ast_token_str(Buf *input, Token *token) {
182ATTRIBUTE_NORETURN164ATTRIBUTE_NORETURN
183static void ast_invalid_token_error(ParseContext *pc, Token *token) {165static void ast_invalid_token_error(ParseContext *pc, Token *token) {
184 Buf token_value = ast_token_str(pc->buf, token);166 Buf token_value = ast_token_str(pc->buf, token);
185 ast_error_exit(pc, token, NULL, "invalid token: '%s'", buf_ptr(&token_value));167 ast_error(pc, token, "invalid token: '%s'", buf_ptr(&token_value));
186}168}
187169
188static AstNode *ast_create_node_no_line_info(ParseContext *pc, NodeType type) {170static AstNode *ast_create_node_no_line_info(ParseContext *pc, NodeType type) {
...@@ -232,13 +214,8 @@ static Token *eat_token_if(ParseContext *pc, TokenId id) {...@@ -232,13 +214,8 @@ static Token *eat_token_if(ParseContext *pc, TokenId id) {
232214
233static Token *expect_token(ParseContext *pc, TokenId id) {215static Token *expect_token(ParseContext *pc, TokenId id) {
234 Token *res = eat_token(pc);216 Token *res = eat_token(pc);
235 if (res->id != id) {217 if (res->id != id)
236 ErrorMsg *note = NULL;218 ast_error(pc, res, "expected token '%s', found '%s'", token_name(id), token_name(res->id));
237 if (res->id == TokenIdAmpersandAmpersand) {
238 note = ast_error(pc, res, "did you mean to use `and`?");
239 }
240 ast_error_exit(pc, res, note, "expected token '%s', found '%s'", token_name(id), token_name(res->id));
241 }
242219
243 return res;220 return res;
244}221}
...@@ -860,7 +837,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {...@@ -860,7 +837,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
860 if (param_decl->data.param_decl.is_var_args)837 if (param_decl->data.param_decl.is_var_args)
861 res->data.fn_proto.is_var_args = true;838 res->data.fn_proto.is_var_args = true;
862 if (i != params.length - 1 && res->data.fn_proto.is_var_args)839 if (i != params.length - 1 && res->data.fn_proto.is_var_args)
863 ast_error_exit(pc, first, NULL, "Function prototype have varargs as a none last paramter.");840 ast_error(pc, first, "Function prototype have varargs as a none last paramter.");
864 }841 }
865 return res;842 return res;
866}843}
src/tokenizer.cpp+3-12
...@@ -199,7 +199,6 @@ enum TokenizeState {...@@ -199,7 +199,6 @@ enum TokenizeState {
199 TokenizeStateSawDash,199 TokenizeStateSawDash,
200 TokenizeStateSawMinusPercent,200 TokenizeStateSawMinusPercent,
201 TokenizeStateSawAmpersand,201 TokenizeStateSawAmpersand,
202 TokenizeStateSawAmpersandAmpersand,
203 TokenizeStateSawCaret,202 TokenizeStateSawCaret,
204 TokenizeStateSawBar,203 TokenizeStateSawBar,
205 TokenizeStateSawBarBar,204 TokenizeStateSawBarBar,
...@@ -887,15 +886,14 @@ void tokenize(Buf *buf, Tokenization *out) {...@@ -887,15 +886,14 @@ void tokenize(Buf *buf, Tokenization *out) {
887 break;886 break;
888 case TokenizeStateSawAmpersand:887 case TokenizeStateSawAmpersand:
889 switch (c) {888 switch (c) {
889 case '&':
890 tokenize_error(&t, "`&&` is invalid. Note that `and` is boolean AND.");
891 break;
890 case '=':892 case '=':
891 set_token_id(&t, t.cur_tok, TokenIdBitAndEq);893 set_token_id(&t, t.cur_tok, TokenIdBitAndEq);
892 end_token(&t);894 end_token(&t);
893 t.state = TokenizeStateStart;895 t.state = TokenizeStateStart;
894 break;896 break;
895 case '&':
896 set_token_id(&t, t.cur_tok, TokenIdAmpersandAmpersand);
897 t.state = TokenizeStateSawAmpersandAmpersand;
898 break;
899 default:897 default:
900 t.pos -= 1;898 t.pos -= 1;
901 end_token(&t);899 end_token(&t);
...@@ -903,11 +901,6 @@ void tokenize(Buf *buf, Tokenization *out) {...@@ -903,11 +901,6 @@ void tokenize(Buf *buf, Tokenization *out) {
903 continue;901 continue;
904 }902 }
905 break;903 break;
906 case TokenizeStateSawAmpersandAmpersand:
907 t.pos -= 1;
908 end_token(&t);
909 t.state = TokenizeStateStart;
910 continue;
911 case TokenizeStateSawCaret:904 case TokenizeStateSawCaret:
912 switch (c) {905 switch (c) {
913 case '=':906 case '=':
...@@ -1478,7 +1471,6 @@ void tokenize(Buf *buf, Tokenization *out) {...@@ -1478,7 +1471,6 @@ void tokenize(Buf *buf, Tokenization *out) {
1478 case TokenizeStateSawPlus:1471 case TokenizeStateSawPlus:
1479 case TokenizeStateSawDash:1472 case TokenizeStateSawDash:
1480 case TokenizeStateSawAmpersand:1473 case TokenizeStateSawAmpersand:
1481 case TokenizeStateSawAmpersandAmpersand:
1482 case TokenizeStateSawCaret:1474 case TokenizeStateSawCaret:
1483 case TokenizeStateSawBar:1475 case TokenizeStateSawBar:
1484 case TokenizeStateSawEq:1476 case TokenizeStateSawEq:
...@@ -1526,7 +1518,6 @@ void tokenize(Buf *buf, Tokenization *out) {...@@ -1526,7 +1518,6 @@ void tokenize(Buf *buf, Tokenization *out) {
1526const char * token_name(TokenId id) {1518const char * token_name(TokenId id) {
1527 switch (id) {1519 switch (id) {
1528 case TokenIdAmpersand: return "&";1520 case TokenIdAmpersand: return "&";
1529 case TokenIdAmpersandAmpersand: return "&&";
1530 case TokenIdArrow: return "->";1521 case TokenIdArrow: return "->";
1531 case TokenIdAtSign: return "@";1522 case TokenIdAtSign: return "@";
1532 case TokenIdBang: return "!";1523 case TokenIdBang: return "!";
src/tokenizer.hpp-1
...@@ -14,7 +14,6 @@...@@ -14,7 +14,6 @@
1414
15enum TokenId {15enum TokenId {
16 TokenIdAmpersand,16 TokenIdAmpersand,
17 TokenIdAmpersandAmpersand,
18 TokenIdArrow,17 TokenIdArrow,
19 TokenIdAtSign,18 TokenIdAtSign,
20 TokenIdBang,19 TokenIdBang,
test/compile_errors.zig+74-78
...@@ -2,33 +2,28 @@ const tests = @import("tests.zig");...@@ -2,33 +2,28 @@ const tests = @import("tests.zig");
22
3pub fn addCases(cases: *tests.CompileErrorContext) void {3pub fn addCases(cases: *tests.CompileErrorContext) void {
4 cases.add(4 cases.add(
5 "Use of && in place of `and`",5 "attempted `&&`",
6 \\export fn entry() void {6 \\export fn entry(a: bool, b: bool) i32 {
7 \\ if (true && false) return;7 \\ if (a && b) {
8 \\}8 \\ return 1234;
9 ,9 \\ }
10 ".tmp_source.zig:2:14: error: expected token ')', found '&&'",10 \\ return 5678;
11 ".tmp_source.zig:2:14: note: did you mean to use `and`?",
12 );
13
14 cases.add(
15 "Use of || in place of `or` (using comptime_int)",
16 \\export fn entry() void {
17 \\ if (1 || 0) return;
18 \\}11 \\}
19 ,12 ,
20 ".tmp_source.zig:2:9: error: expected ErrorSet type, found 'comptime_int'",13 ".tmp_source.zig:2:11: error: `&&` is invalid. Note that `and` is boolean AND.",
21 ".tmp_source.zig:2:11: note: did you mean to use `or`?",
22 );14 );
2315
24 cases.add(16 cases.add(
25 "Use of || in place of `or` (using booleans)",17 "attempted `||` on boolean values",
26 \\export fn entry() void {18 \\export fn entry(a: bool, b: bool) i32 {
27 \\ if (true || false) return;19 \\ if (a || b) {
20 \\ return 1234;
21 \\ }
22 \\ return 5678;
28 \\}23 \\}
29 ,24 ,
30 ".tmp_source.zig:2:9: error: expected ErrorSet type, found 'bool'",25 ".tmp_source.zig:2:9: error: expected error set type, found 'bool'",
31 ".tmp_source.zig:2:14: note: did you mean to use `or`?",26 ".tmp_source.zig:2:11: note: `||` merges error sets; `or` performs boolean OR",
32 );27 );
3328
34 cases.add(29 cases.add(
...@@ -98,7 +93,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -98,7 +93,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
98 \\ do_the_thing(bar);93 \\ do_the_thing(bar);
99 \\}94 \\}
100 ,95 ,
101 ".tmp_source.zig:4:18: error: expected 'fn(i32) void' type, found 'fn(bool) void",96 ".tmp_source.zig:4:18: error: expected type 'fn(i32) void', found 'fn(bool) void",
102 ".tmp_source.zig:4:18: note: parameter 0: 'bool' cannot cast into 'i32'",97 ".tmp_source.zig:4:18: note: parameter 0: 'bool' cannot cast into 'i32'",
103 );98 );
10499
...@@ -134,7 +129,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -134,7 +129,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
134 ,129 ,
135 ".tmp_source.zig:3:31: error: integer value 300 cannot be implicitly casted to type 'u8'",130 ".tmp_source.zig:3:31: error: integer value 300 cannot be implicitly casted to type 'u8'",
136 ".tmp_source.zig:7:22: error: integer value 300 cannot be implicitly casted to type 'u8'",131 ".tmp_source.zig:7:22: error: integer value 300 cannot be implicitly casted to type 'u8'",
137 ".tmp_source.zig:11:20: error: expected 'u8' type, found 'u16'",132 ".tmp_source.zig:11:20: error: expected type 'u8', found 'u16'",
138 );133 );
139134
140 cases.add(135 cases.add(
...@@ -154,7 +149,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -154,7 +149,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
154 \\149 \\
155 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }150 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
156 ,151 ,
157 ".tmp_source.zig:2:14: error: expected 'f32' type, found 'f64'",152 ".tmp_source.zig:2:14: error: expected type 'f32', found 'f64'",
158 );153 );
159154
160 cases.add(155 cases.add(
...@@ -202,7 +197,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -202,7 +197,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
202 \\ var ptr2: *c_void = &b;197 \\ var ptr2: *c_void = &b;
203 \\}198 \\}
204 ,199 ,
205 ".tmp_source.zig:5:26: error: expected '*c_void' type, found '**u32'",200 ".tmp_source.zig:5:26: error: expected type '*c_void', found '**u32'",
206 );201 );
207202
208 cases.add(203 cases.add(
...@@ -252,7 +247,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -252,7 +247,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
252 \\ const sliceA: []u8 = &buffer;247 \\ const sliceA: []u8 = &buffer;
253 \\}248 \\}
254 ,249 ,
255 ".tmp_source.zig:3:27: error: expected '[]u8' type, found '*const [1]u8'",250 ".tmp_source.zig:3:27: error: expected type '[]u8', found '*const [1]u8'",
256 );251 );
257252
258 cases.add(253 cases.add(
...@@ -297,9 +292,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -297,9 +292,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
297 \\ const Errors = error{} || u16;292 \\ const Errors = error{} || u16;
298 \\}293 \\}
299 ,294 ,
300 ".tmp_source.zig:2:20: error: expected ErrorSet type, found 'u8'",295 ".tmp_source.zig:2:20: error: expected error set type, found type 'u8'",
301 ".tmp_source.zig:2:23: note: did you mean to use `or`?",296 ".tmp_source.zig:2:23: note: `||` merges error sets; `or` performs boolean OR",
302 ".tmp_source.zig:5:31: error: expected ErrorSet type, found 'u16'",297 ".tmp_source.zig:5:31: error: expected error set type, found type 'u16'",
298 ".tmp_source.zig:5:28: note: `||` merges error sets; `or` performs boolean OR",
303 );299 );
304300
305 cases.add(301 cases.add(
...@@ -794,7 +790,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -794,7 +790,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
794 \\790 \\
795 \\fn bar(x: *b.Foo) void {}791 \\fn bar(x: *b.Foo) void {}
796 ,792 ,
797 ".tmp_source.zig:6:10: error: expected '*Foo' type, found '*Foo'",793 ".tmp_source.zig:6:10: error: expected type '*Foo', found '*Foo'",
798 ".tmp_source.zig:6:10: note: pointer type child 'Foo' cannot cast into pointer type child 'Foo'",794 ".tmp_source.zig:6:10: note: pointer type child 'Foo' cannot cast into pointer type child 'Foo'",
799 "a.zig:1:17: note: Foo declared here",795 "a.zig:1:17: note: Foo declared here",
800 "b.zig:1:17: note: Foo declared here",796 "b.zig:1:17: note: Foo declared here",
...@@ -864,7 +860,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -864,7 +860,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
864 \\ var y = p.*;860 \\ var y = p.*;
865 \\}861 \\}
866 ,862 ,
867 ".tmp_source.zig:4:23: error: expected '*?*i32' type, found '**i32'",863 ".tmp_source.zig:4:23: error: expected type '*?*i32', found '**i32'",
868 );864 );
869865
870 cases.add(866 cases.add(
...@@ -873,7 +869,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -873,7 +869,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
873 \\ const x: [*]const bool = true;869 \\ const x: [*]const bool = true;
874 \\}870 \\}
875 ,871 ,
876 ".tmp_source.zig:2:30: error: expected '[*]const bool' type, found 'bool'",872 ".tmp_source.zig:2:30: error: expected type '[*]const bool', found 'bool'",
877 );873 );
878874
879 cases.add(875 cases.add(
...@@ -918,7 +914,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -918,7 +914,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
918 \\ var rule_set = try Foo.init();914 \\ var rule_set = try Foo.init();
919 \\}915 \\}
920 ,916 ,
921 ".tmp_source.zig:2:13: error: expected 'i32' type, found 'type'",917 ".tmp_source.zig:2:13: error: expected type 'i32', found 'type'",
922 );918 );
923919
924 cases.add(920 cases.add(
...@@ -952,7 +948,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -952,7 +948,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
952 \\ return null;948 \\ return null;
953 \\}949 \\}
954 ,950 ,
955 ".tmp_source.zig:5:34: error: expected '?NextError!i32' type, found '?OtherError!i32'",951 ".tmp_source.zig:5:34: error: expected type '?NextError!i32', found '?OtherError!i32'",
956 ".tmp_source.zig:5:34: note: optional type child 'OtherError!i32' cannot cast into optional type child 'NextError!i32'",952 ".tmp_source.zig:5:34: note: optional type child 'OtherError!i32' cannot cast into optional type child 'NextError!i32'",
957 ".tmp_source.zig:5:34: note: error set 'OtherError' cannot cast into error set 'NextError'",953 ".tmp_source.zig:5:34: note: error set 'OtherError' cannot cast into error set 'NextError'",
958 ".tmp_source.zig:2:26: note: 'error.OutOfMemory' not a member of destination error set",954 ".tmp_source.zig:2:26: note: 'error.OutOfMemory' not a member of destination error set",
...@@ -1022,7 +1018,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1022,7 +1018,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1022 \\ @panic(e);1018 \\ @panic(e);
1023 \\}1019 \\}
1024 ,1020 ,
1025 ".tmp_source.zig:3:12: error: expected '[]const u8' type, found 'error{Foo}'",1021 ".tmp_source.zig:3:12: error: expected type '[]const u8', found 'error{Foo}'",
1026 );1022 );
10271023
1028 cases.add(1024 cases.add(
...@@ -1050,7 +1046,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1050,7 +1046,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1050 \\ return error.ShouldBeCompileError;1046 \\ return error.ShouldBeCompileError;
1051 \\}1047 \\}
1052 ,1048 ,
1053 ".tmp_source.zig:6:17: error: expected 'void' type, found 'error{ShouldBeCompileError}'",1049 ".tmp_source.zig:6:17: error: expected type 'void', found 'error{ShouldBeCompileError}'",
1054 );1050 );
10551051
1056 cases.add(1052 cases.add(
...@@ -1093,7 +1089,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1093,7 +1089,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1093 \\ a(c);1089 \\ a(c);
1094 \\}1090 \\}
1095 ,1091 ,
1096 ".tmp_source.zig:8:7: error: expected 'fn(*const u8) void' type, found 'fn(u8) void'",1092 ".tmp_source.zig:8:7: error: expected type 'fn(*const u8) void', found 'fn(u8) void'",
1097 );1093 );
10981094
1099 cases.add(1095 cases.add(
...@@ -1175,7 +1171,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1175,7 +1171,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1175 \\ E.One => {},1171 \\ E.One => {},
1176 \\ }1172 \\ }
1177 \\}1173 \\}
1178 , ".tmp_source.zig:9:10: error: expected 'usize' type, found 'E'");1174 , ".tmp_source.zig:9:10: error: expected type 'usize', found 'E'");
11791175
1180 cases.add(1176 cases.add(
1181 "range operator in switch used on error set",1177 "range operator in switch used on error set",
...@@ -1221,7 +1217,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1221,7 +1217,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1221 \\ const z = i32!i32;1217 \\ const z = i32!i32;
1222 \\}1218 \\}
1223 ,1219 ,
1224 ".tmp_source.zig:2:15: error: expected ErrorSet type, found 'i32'",1220 ".tmp_source.zig:2:15: error: expected error set type, found type 'i32'",
1225 );1221 );
12261222
1227 cases.add(1223 cases.add(
...@@ -1271,7 +1267,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1271,7 +1267,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1271 \\ return error.B;1267 \\ return error.B;
1272 \\}1268 \\}
1273 ,1269 ,
1274 ".tmp_source.zig:3:35: error: expected 'SmallErrorSet!i32' type, found 'anyerror!i32'",1270 ".tmp_source.zig:3:35: error: expected type 'SmallErrorSet!i32', found 'anyerror!i32'",
1275 ".tmp_source.zig:3:35: note: error set 'anyerror' cannot cast into error set 'SmallErrorSet'",1271 ".tmp_source.zig:3:35: note: error set 'anyerror' cannot cast into error set 'SmallErrorSet'",
1276 ".tmp_source.zig:3:35: note: cannot cast global error set into smaller set",1272 ".tmp_source.zig:3:35: note: cannot cast global error set into smaller set",
1277 );1273 );
...@@ -1286,7 +1282,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1286,7 +1282,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1286 \\ return error.B;1282 \\ return error.B;
1287 \\}1283 \\}
1288 ,1284 ,
1289 ".tmp_source.zig:3:31: error: expected 'SmallErrorSet' type, found 'anyerror'",1285 ".tmp_source.zig:3:31: error: expected type 'SmallErrorSet', found 'anyerror'",
1290 ".tmp_source.zig:3:31: note: cannot cast global error set into smaller set",1286 ".tmp_source.zig:3:31: note: cannot cast global error set into smaller set",
1291 );1287 );
12921288
...@@ -1313,7 +1309,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1313,7 +1309,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1313 \\ var x: Set2 = set1;1309 \\ var x: Set2 = set1;
1314 \\}1310 \\}
1315 ,1311 ,
1316 ".tmp_source.zig:7:19: error: expected 'Set2' type, found 'Set1'",1312 ".tmp_source.zig:7:19: error: expected type 'Set2', found 'Set1'",
1317 ".tmp_source.zig:1:23: note: 'error.B' not a member of destination error set",1313 ".tmp_source.zig:1:23: note: 'error.B' not a member of destination error set",
1318 );1314 );
13191315
...@@ -1853,7 +1849,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1853,7 +1849,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1853 \\fn a() noreturn {return;}1849 \\fn a() noreturn {return;}
1854 \\export fn entry() void { a(); }1850 \\export fn entry() void { a(); }
1855 ,1851 ,
1856 ".tmp_source.zig:1:18: error: expected 'noreturn' type, found 'void'",1852 ".tmp_source.zig:1:18: error: expected type 'noreturn', found 'void'",
1857 );1853 );
18581854
1859 cases.add(1855 cases.add(
...@@ -1861,7 +1857,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1861,7 +1857,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1861 \\fn a() i32 {}1857 \\fn a() i32 {}
1862 \\export fn entry() void { _ = a(); }1858 \\export fn entry() void { _ = a(); }
1863 ,1859 ,
1864 ".tmp_source.zig:1:12: error: expected 'i32' type, found 'void'",1860 ".tmp_source.zig:1:12: error: expected type 'i32', found 'void'",
1865 );1861 );
18661862
1867 cases.add(1863 cases.add(
...@@ -1967,7 +1963,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1967,7 +1963,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1967 \\ return a;1963 \\ return a;
1968 \\}1964 \\}
1969 ,1965 ,
1970 ".tmp_source.zig:3:12: error: expected 'i32' type, found '[*]const u8'",1966 ".tmp_source.zig:3:12: error: expected type 'i32', found '[*]const u8'",
1971 );1967 );
19721968
1973 cases.add(1969 cases.add(
...@@ -1976,7 +1972,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1976,7 +1972,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1976 \\ if (0) {}1972 \\ if (0) {}
1977 \\}1973 \\}
1978 ,1974 ,
1979 ".tmp_source.zig:2:9: error: expected 'bool' type, found 'comptime_int'",1975 ".tmp_source.zig:2:9: error: expected type 'bool', found 'comptime_int'",
1980 );1976 );
19811977
1982 cases.add(1978 cases.add(
...@@ -2071,8 +2067,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -2071,8 +2067,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
2071 \\ array[bad] = array[bad];2067 \\ array[bad] = array[bad];
2072 \\}2068 \\}
2073 ,2069 ,
2074 ".tmp_source.zig:4:11: error: expected 'usize' type, found 'bool'",2070 ".tmp_source.zig:4:11: error: expected type 'usize', found 'bool'",
2075 ".tmp_source.zig:4:24: error: expected 'usize' type, found 'bool'",2071 ".tmp_source.zig:4:24: error: expected type 'usize', found 'bool'",
2076 );2072 );
20772073
2078 cases.add(2074 cases.add(
...@@ -2486,7 +2482,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -2486,7 +2482,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
2486 \\fn foo() *const i32 { return y; }2482 \\fn foo() *const i32 { return y; }
2487 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }2483 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
2488 ,2484 ,
2489 ".tmp_source.zig:3:30: error: expected '*const i32' type, found '*const comptime_int'",2485 ".tmp_source.zig:3:30: error: expected type '*const i32', found '*const comptime_int'",
2490 );2486 );
24912487
2492 cases.add(2488 cases.add(
...@@ -2564,7 +2560,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -2564,7 +2560,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
2564 \\fn c() i32 {return 2;}2560 \\fn c() i32 {return 2;}
2565 \\export fn entry() usize { return @sizeOf(@typeOf(fns)); }2561 \\export fn entry() usize { return @sizeOf(@typeOf(fns)); }
2566 ,2562 ,
2567 ".tmp_source.zig:1:27: error: expected 'fn() void' type, found 'fn() i32'",2563 ".tmp_source.zig:1:27: error: expected type 'fn() void', found 'fn() i32'",
2568 );2564 );
25692565
2570 cases.add(2566 cases.add(
...@@ -2576,7 +2572,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -2576,7 +2572,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
2576 \\2572 \\
2577 \\export fn entry() usize { return @sizeOf(@typeOf(fns)); }2573 \\export fn entry() usize { return @sizeOf(@typeOf(fns)); }
2578 ,2574 ,
2579 ".tmp_source.zig:1:36: error: expected 'fn(i32) i32' type, found 'extern fn(i32) i32'",2575 ".tmp_source.zig:1:36: error: expected type 'fn(i32) i32', found 'extern fn(i32) i32'",
2580 );2576 );
25812577
2582 cases.add(2578 cases.add(
...@@ -2680,7 +2676,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -2680,7 +2676,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
2680 \\2676 \\
2681 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }2677 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
2682 ,2678 ,
2683 ".tmp_source.zig:1:16: error: expected '*u8' type, found '(null)'",2679 ".tmp_source.zig:1:16: error: expected type '*u8', found '(null)'",
2684 );2680 );
26852681
2686 cases.add(2682 cases.add(
...@@ -3320,7 +3316,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3320,7 +3316,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3320 \\}3316 \\}
3321 \\fn something() anyerror!void { }3317 \\fn something() anyerror!void { }
3322 ,3318 ,
3323 ".tmp_source.zig:2:5: error: expected 'void' type, found 'anyerror'",3319 ".tmp_source.zig:2:5: error: expected type 'void', found 'anyerror'",
3324 ".tmp_source.zig:1:15: note: return type declared here",3320 ".tmp_source.zig:1:15: note: return type declared here",
3325 );3321 );
33263322
...@@ -3499,7 +3495,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3499,7 +3495,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3499 \\ derp.init();3495 \\ derp.init();
3500 \\}3496 \\}
3501 ,3497 ,
3502 ".tmp_source.zig:14:5: error: expected 'i32' type, found 'Foo'",3498 ".tmp_source.zig:14:5: error: expected type 'i32', found 'Foo'",
3503 );3499 );
35043500
3505 cases.add(3501 cases.add(
...@@ -3529,7 +3525,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3529,7 +3525,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3529 \\ x.init();3525 \\ x.init();
3530 \\}3526 \\}
3531 ,3527 ,
3532 ".tmp_source.zig:23:5: error: expected '*Allocator' type, found '*List'",3528 ".tmp_source.zig:23:5: error: expected type '*Allocator', found '*List'",
3533 );3529 );
35343530
3535 cases.add(3531 cases.add(
...@@ -3701,7 +3697,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3701,7 +3697,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3701 \\3697 \\
3702 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }3698 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
3703 ,3699 ,
3704 ".tmp_source.zig:8:26: error: expected '*const u3' type, found '*align(:3:1) const u3'",3700 ".tmp_source.zig:8:26: error: expected type '*const u3', found '*align(:3:1) const u3'",
3705 );3701 );
37063702
3707 cases.add(3703 cases.add(
...@@ -3830,7 +3826,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3830,7 +3826,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3830 \\3826 \\
3831 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }3827 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
3832 ,3828 ,
3833 ".tmp_source.zig:4:19: error: expected '*[]const u8' type, found '*const []const u8'",3829 ".tmp_source.zig:4:19: error: expected type '*[]const u8', found '*const []const u8'",
3834 );3830 );
38353831
3836 cases.addCase(x: {3832 cases.addCase(x: {
...@@ -3862,7 +3858,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3862,7 +3858,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3862 \\ foo(global_array);3858 \\ foo(global_array);
3863 \\}3859 \\}
3864 ,3860 ,
3865 ".tmp_source.zig:4:9: error: expected '[]i32' type, found '[10]i32'",3861 ".tmp_source.zig:4:9: error: expected type '[]i32', found '[10]i32'",
3866 );3862 );
38673863
3868 cases.add(3864 cases.add(
...@@ -3871,7 +3867,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3871,7 +3867,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3871 \\ return @ptrCast(usize, a);3867 \\ return @ptrCast(usize, a);
3872 \\}3868 \\}
3873 ,3869 ,
3874 ".tmp_source.zig:2:21: error: expected Pointer type, found 'usize'",3870 ".tmp_source.zig:2:21: error: expected pointer, found 'usize'",
3875 );3871 );
38763872
3877 cases.add(3873 cases.add(
...@@ -3918,7 +3914,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3918,7 +3914,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3918 \\ return @fieldParentPtr(Foo, "a", a);3914 \\ return @fieldParentPtr(Foo, "a", a);
3919 \\}3915 \\}
3920 ,3916 ,
3921 ".tmp_source.zig:3:28: error: expected Struct type, found 'i32'",3917 ".tmp_source.zig:3:28: error: expected struct type, found 'i32'",
3922 );3918 );
39233919
3924 cases.add(3920 cases.add(
...@@ -3942,7 +3938,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3942,7 +3938,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3942 \\ return @fieldParentPtr(Foo, "a", a);3938 \\ return @fieldParentPtr(Foo, "a", a);
3943 \\}3939 \\}
3944 ,3940 ,
3945 ".tmp_source.zig:5:38: error: expected Pointer type, found 'i32'",3941 ".tmp_source.zig:5:38: error: expected pointer, found 'i32'",
3946 );3942 );
39473943
3948 cases.add(3944 cases.add(
...@@ -3983,7 +3979,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3983,7 +3979,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3983 \\ return @byteOffsetOf(Foo, "a",);3979 \\ return @byteOffsetOf(Foo, "a",);
3984 \\}3980 \\}
3985 ,3981 ,
3986 ".tmp_source.zig:3:26: error: expected Struct type, found 'i32'",3982 ".tmp_source.zig:3:26: error: expected struct type, found 'i32'",
3987 );3983 );
39883984
3989 cases.add(3985 cases.add(
...@@ -4097,7 +4093,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4097,7 +4093,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4097 \\}4093 \\}
4098 \\fn bar() ?i32 { return 1; }4094 \\fn bar() ?i32 { return 1; }
4099 ,4095 ,
4100 ".tmp_source.zig:2:15: error: expected 'bool' type, found '?i32'",4096 ".tmp_source.zig:2:15: error: expected type 'bool', found '?i32'",
4101 );4097 );
41024098
4103 cases.add(4099 cases.add(
...@@ -4107,7 +4103,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4107,7 +4103,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4107 \\}4103 \\}
4108 \\fn bar() anyerror!i32 { return 1; }4104 \\fn bar() anyerror!i32 { return 1; }
4109 ,4105 ,
4110 ".tmp_source.zig:2:15: error: expected 'bool' type, found 'anyerror!i32'",4106 ".tmp_source.zig:2:15: error: expected type 'bool', found 'anyerror!i32'",
4111 );4107 );
41124108
4113 cases.add(4109 cases.add(
...@@ -4368,7 +4364,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4368,7 +4364,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4368 \\ return @ptrToInt(x);4364 \\ return @ptrToInt(x);
4369 \\}4365 \\}
4370 ,4366 ,
4371 ".tmp_source.zig:2:22: error: expected Pointer type, found 'i32'",4367 ".tmp_source.zig:2:22: error: expected pointer, found 'i32'",
4372 );4368 );
43734369
4374 cases.add(4370 cases.add(
...@@ -4404,7 +4400,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4404,7 +4400,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4404 \\ return x << y;4400 \\ return x << y;
4405 \\}4401 \\}
4406 ,4402 ,
4407 ".tmp_source.zig:2:17: error: expected 'u3' type, found 'u8'",4403 ".tmp_source.zig:2:17: error: expected type 'u3', found 'u8'",
4408 );4404 );
44094405
4410 cases.add(4406 cases.add(
...@@ -4433,7 +4429,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4433,7 +4429,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4433 \\ x.* += 1;4429 \\ x.* += 1;
4434 \\}4430 \\}
4435 ,4431 ,
4436 ".tmp_source.zig:8:13: error: expected '*u32' type, found '*align(1) u32'",4432 ".tmp_source.zig:8:13: error: expected type '*u32', found '*align(1) u32'",
4437 );4433 );
44384434
4439 cases.add(4435 cases.add(
...@@ -4477,7 +4473,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4477,7 +4473,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4477 \\ @alignCast(4, u32(3));4473 \\ @alignCast(4, u32(3));
4478 \\}4474 \\}
4479 ,4475 ,
4480 ".tmp_source.zig:2:22: error: expected pointer or slice type, found 'u32'",4476 ".tmp_source.zig:2:22: error: expected pointer or slice, found 'u32'",
4481 );4477 );
44824478
4483 cases.add(4479 cases.add(
...@@ -4490,7 +4486,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4490,7 +4486,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4490 \\}4486 \\}
4491 \\fn alignedSmall() align(4) i32 { return 1234; }4487 \\fn alignedSmall() align(4) i32 { return 1234; }
4492 ,4488 ,
4493 ".tmp_source.zig:2:35: error: expected 'fn() align(8) i32' type, found 'fn() align(4) i32'",4489 ".tmp_source.zig:2:35: error: expected type 'fn() align(8) i32', found 'fn() align(4) i32'",
4494 );4490 );
44954491
4496 cases.add(4492 cases.add(
...@@ -4502,7 +4498,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4502,7 +4498,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4502 \\ return x == 5678;4498 \\ return x == 5678;
4503 \\}4499 \\}
4504 ,4500 ,
4505 ".tmp_source.zig:4:32: error: expected '*i32' type, found '*align(1) i32'",4501 ".tmp_source.zig:4:32: error: expected type '*i32', found '*align(1) i32'",
4506 );4502 );
45074503
4508 cases.add(4504 cases.add(
...@@ -4537,7 +4533,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4537,7 +4533,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4537 \\ bar(@ptrCast(*c_void, &x));4533 \\ bar(@ptrCast(*c_void, &x));
4538 \\}4534 \\}
4539 ,4535 ,
4540 ".tmp_source.zig:5:9: error: expected '*Derp' type, found '*c_void'",4536 ".tmp_source.zig:5:9: error: expected type '*Derp', found '*c_void'",
4541 );4537 );
45424538
4543 cases.add(4539 cases.add(
...@@ -4583,7 +4579,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4583,7 +4579,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4583 \\ while (!@cmpxchgWeak(i32, &x, 1234, 5678, u32(1234), u32(1234))) {}4579 \\ while (!@cmpxchgWeak(i32, &x, 1234, 5678, u32(1234), u32(1234))) {}
4584 \\}4580 \\}
4585 ,4581 ,
4586 ".tmp_source.zig:3:50: error: expected 'AtomicOrder' type, found 'u32'",4582 ".tmp_source.zig:3:50: error: expected type 'AtomicOrder', found 'u32'",
4587 );4583 );
45884584
4589 cases.add(4585 cases.add(
...@@ -4593,7 +4589,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4593,7 +4589,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4593 \\ @export("entry", entry, u32(1234));4589 \\ @export("entry", entry, u32(1234));
4594 \\}4590 \\}
4595 ,4591 ,
4596 ".tmp_source.zig:3:32: error: expected 'GlobalLinkage' type, found 'u32'",4592 ".tmp_source.zig:3:32: error: expected type 'GlobalLinkage', found 'u32'",
4597 );4593 );
45984594
4599 cases.add(4595 cases.add(
...@@ -4770,7 +4766,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4770,7 +4766,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4770 \\ _ = @ArgType(i32, 3);4766 \\ _ = @ArgType(i32, 3);
4771 \\}4767 \\}
4772 ,4768 ,
4773 ".tmp_source.zig:2:18: error: expected Fn type, found 'i32'",4769 ".tmp_source.zig:2:18: error: expected function, found 'i32'",
4774 );4770 );
47754771
4776 cases.add(4772 cases.add(
...@@ -4868,7 +4864,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4868,7 +4864,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4868 \\}4864 \\}
4869 \\pub extern fn foo(format: *const u8, ...) void;4865 \\pub extern fn foo(format: *const u8, ...) void;
4870 ,4866 ,
4871 ".tmp_source.zig:2:9: error: expected '*const u8' type, found '[5]u8'",4867 ".tmp_source.zig:2:9: error: expected type '*const u8', found '[5]u8'",
4872 );4868 );
48734869
4874 cases.add(4870 cases.add(
...@@ -4937,7 +4933,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4937,7 +4933,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4937 \\ var x: u2 = Small.Two;4933 \\ var x: u2 = Small.Two;
4938 \\}4934 \\}
4939 ,4935 ,
4940 ".tmp_source.zig:9:22: error: expected 'u2' type, found 'Small'",4936 ".tmp_source.zig:9:22: error: expected type 'u2', found 'Small'",
4941 );4937 );
49424938
4943 cases.add(4939 cases.add(
...@@ -4954,7 +4950,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4954,7 +4950,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4954 \\ var x = @intToEnum(Small, y);4950 \\ var x = @intToEnum(Small, y);
4955 \\}4951 \\}
4956 ,4952 ,
4957 ".tmp_source.zig:10:31: error: expected 'u2' type, found 'u3'",4953 ".tmp_source.zig:10:31: error: expected type 'u2', found 'u3'",
4958 );4954 );
49594955
4960 cases.add(4956 cases.add(
...@@ -5351,7 +5347,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -5351,7 +5347,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
5351 \\ asm volatile ("" : : [bar]"r"(3) : "");5347 \\ asm volatile ("" : : [bar]"r"(3) : "");
5352 \\}5348 \\}
5353 ,5349 ,
5354 ".tmp_source.zig:2:35: error: expected sized integer or sized float type, found comptime_int",5350 ".tmp_source.zig:2:35: error: expected sized integer or sized float, found comptime_int",
5355 );5351 );
53565352
5357 cases.add(5353 cases.add(
...@@ -5360,6 +5356,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -5360,6 +5356,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
5360 \\ asm volatile ("" : : [bar]"r"(3.17) : "");5356 \\ asm volatile ("" : : [bar]"r"(3.17) : "");
5361 \\}5357 \\}
5362 ,5358 ,
5363 ".tmp_source.zig:2:35: error: expected sized integer or sized float type, found comptime_float",5359 ".tmp_source.zig:2:35: error: expected sized integer or sized float, found comptime_float",
5364 );5360 );
5365}5361}