authorgravatar for kris.tate+github@gmail.comkristopher tate <kris.tate+github@gmail.com> 2019-01-26 05:10:40+09:00
committergravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2019-01-25 21:10:40+01:00
log5bf9ffdc5be02e67b57fe9398ad9d13147bfb0c8
treef8c68dbdabe3534f80134f755ec4b1ff007bdc22
parent3bec3b9f9ba49bbc2e7244737c50bdbaa12a6b14

Hint at use of and/or when &&/|| is improperly used (#1886)


6 files changed, 226 insertions(+), 196 deletions(-)

doc/langref.html.in+1-1
......@@ -6024,7 +6024,7 @@ fn add(a: i32, b: i32) i32 {
60246024 This is typically used for type safety when interacting with C code that does not expose struct details.
60256025 Example:
60266026 </p>
6027 {#code_begin|test_err|expected type '*Derp', found '*Wat'#}
6027 {#code_begin|test_err|expected '*Derp' type, found '*Wat'#}
60286028const Derp = @OpaqueType();
60296029const Wat = @OpaqueType();
60306030
src/ir.cpp+95-132
......@@ -9771,13 +9771,19 @@ IrInstruction *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node
97719771 return ir_exec_const_result(codegen, analyzed_executable);
97729772}
97739773
9774static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) {
9774static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value, ZigTypeId wanted_type) {
97759775 if (type_is_invalid(type_value->value.type))
97769776 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
97789784 if (type_value->value.type->id != ZigTypeIdMetaType) {
9779 ir_add_error(ira, type_value,
9780 buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value.type->name)));
9785 ir_add_error( ira, type_value,
9786 buf_sprintf("expected %s type, found '%s'", expected_type_str, buf_ptr(&type_value->value.type->name)));
97819787 return ira->codegen->builtin_types.entry_invalid;
97829788 }
97839789
......@@ -9786,7 +9792,16 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) {
97869792 return ira->codegen->builtin_types.entry_invalid;
97879793
97889794 assert(const_val->data.x_type != nullptr);
9789 return const_val->data.x_type;
9795
9796 ZigType *out_type = const_val->data.x_type;
9797
9798 if (wanted_type != ZigTypeIdInvalid && out_type->id != wanted_type) {
9799 ir_add_error(ira, type_value,
9800 buf_sprintf( "expected %s type, found '%s'", expected_type_str, buf_ptr(&out_type->name)));
9801 return ira->codegen->builtin_types.entry_invalid;
9802 }
9803
9804 return out_type;
97909805}
97919806
97929807static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) {
......@@ -10986,7 +11001,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1098611001 }
1098711002
1098811003 ErrorMsg *parent_msg = ir_add_error_node(ira, source_instr->source_node,
10989 buf_sprintf("expected type '%s', found '%s'",
11004 buf_sprintf("expected '%s' type, found '%s'",
1099011005 buf_ptr(&wanted_type->name),
1099111006 buf_ptr(&actual_type->name)));
1099211007 report_recursive_error(ira, source_instr->source_node, &const_cast_result, parent_msg);
......@@ -12214,7 +12229,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1221412229 size_t op2_array_end;
1221512230 if (op2_type->id == ZigTypeIdArray) {
1221612231 if (op2_type->data.array.child_type != child_type) {
12217 ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'",
12232 ir_add_error(ira, op2, buf_sprintf("expected array of '%s' type, found '%s'",
1221812233 buf_ptr(&child_type->name),
1221912234 buf_ptr(&op2->value.type->name)));
1222012235 return ira->codegen->invalid_instruction;
......@@ -12228,7 +12243,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1222812243 op2_val->data.x_ptr.data.base_array.is_cstr)
1222912244 {
1223012245 if (child_type != ira->codegen->builtin_types.entry_u8) {
12231 ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'",
12246 ir_add_error(ira, op2, buf_sprintf("expected array of '%s' type, found '%s'",
1223212247 buf_ptr(&child_type->name),
1223312248 buf_ptr(&op2->value.type->name)));
1223412249 return ira->codegen->invalid_instruction;
......@@ -12239,7 +12254,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1223912254 } else if (is_slice(op2_type)) {
1224012255 ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry;
1224112256 if (ptr_type->data.pointer.child_type != child_type) {
12242 ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'",
12257 ir_add_error(ira, op2, buf_sprintf("expected array of '%s' type, found '%s'",
1224312258 buf_ptr(&child_type->name),
1224412259 buf_ptr(&op2->value.type->name)));
1224512260 return ira->codegen->invalid_instruction;
......@@ -12253,7 +12268,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1225312268 op2_array_end = bigint_as_unsigned(&len_val->data.x_bigint);
1225412269 } else {
1225512270 ir_add_error(ira, op2,
12256 buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value.type->name)));
12271 buf_sprintf("expected array or C string literal type, found '%s'", buf_ptr(&op2->value.type->name)));
1225712272 return ira->codegen->invalid_instruction;
1225812273 }
1225912274
......@@ -12388,26 +12403,22 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *
1238812403}
1238912404
1239012405static IrInstruction *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstructionBinOp *instruction) {
12391 ZigType *op1_type = ir_resolve_type(ira, instruction->op1->child);
12392 if (type_is_invalid(op1_type))
12393 return ira->codegen->invalid_instruction;
12394
12395 if (op1_type->id != ZigTypeIdErrorSet) {
12396 ir_add_error(ira, instruction->op1,
12397 buf_sprintf("expected error set type, found '%s'", buf_ptr(&op1_type->name)));
12406 ZigType *op1_type = ir_resolve_type(ira, instruction->op1->child, ZigTypeIdErrorSet);
12407 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 }
1239812415 return ira->codegen->invalid_instruction;
1239912416 }
1240012417
12401 ZigType *op2_type = ir_resolve_type(ira, instruction->op2->child);
12418 ZigType *op2_type = ir_resolve_type(ira, instruction->op2->child, ZigTypeIdErrorSet);
1240212419 if (type_is_invalid(op2_type))
1240312420 return ira->codegen->invalid_instruction;
1240412421
12405 if (op2_type->id != ZigTypeIdErrorSet) {
12406 ir_add_error(ira, instruction->op2,
12407 buf_sprintf("expected error set type, found '%s'", buf_ptr(&op2_type->name)));
12408 return ira->codegen->invalid_instruction;
12409 }
12410
1241112422 if (type_is_global_error_set(op1_type) ||
1241212423 type_is_global_error_set(op2_type))
1241312424 {
......@@ -12495,7 +12506,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruct
1249512506 IrInstruction *var_type = nullptr;
1249612507 if (decl_var_instruction->var_type != nullptr) {
1249712508 var_type = decl_var_instruction->var_type->child;
12498 ZigType *proposed_type = ir_resolve_type(ira, var_type);
12509 ZigType *proposed_type = ir_resolve_type(ira, var_type, ZigTypeIdInvalid);
1249912510 explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type);
1250012511 if (type_is_invalid(explicit_type)) {
1250112512 var->value->type = ira->codegen->builtin_types.entry_invalid;
......@@ -12824,21 +12835,14 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira,
1282412835{
1282512836 Error err;
1282612837
12827 ZigType *err_set_type = ir_resolve_type(ira, instruction->err_set->child);
12838 ZigType *err_set_type = ir_resolve_type(ira, instruction->err_set->child, ZigTypeIdErrorSet);
1282812839 if (type_is_invalid(err_set_type))
1282912840 return ira->codegen->invalid_instruction;
1283012841
12831 ZigType *payload_type = ir_resolve_type(ira, instruction->payload->child);
12842 ZigType *payload_type = ir_resolve_type(ira, instruction->payload->child, ZigTypeIdInvalid);
1283212843 if (type_is_invalid(payload_type))
1283312844 return ira->codegen->invalid_instruction;
1283412845
12835 if (err_set_type->id != ZigTypeIdErrorSet) {
12836 ir_add_error(ira, instruction->err_set->child,
12837 buf_sprintf("expected error set type, found type '%s'",
12838 buf_ptr(&err_set_type->name)));
12839 return ira->codegen->invalid_instruction;
12840 }
12841
1284212846 if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown)))
1284312847 return ira->codegen->invalid_instruction;
1284412848 ZigType *result_type = get_error_union_type(ira->codegen, err_set_type, payload_type);
......@@ -12900,7 +12904,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *c
1290012904 ZigType *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type;
1290112905 if (alloc_fn_type->id != ZigTypeIdFn) {
1290212906 ir_add_error(ira, &call_instruction->base,
12903 buf_sprintf("expected allocation function, found '%s'", buf_ptr(&alloc_fn_type->name)));
12907 buf_sprintf("expected allocation function type, found '%s'", buf_ptr(&alloc_fn_type->name)));
1290412908 return ira->codegen->invalid_instruction;
1290512909 }
1290612910
......@@ -13692,7 +13696,7 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC
1369213696
1369313697 if (is_comptime || instr_is_comptime(fn_ref)) {
1369413698 if (fn_ref->value.type->id == ZigTypeIdMetaType) {
13695 ZigType *dest_type = ir_resolve_type(ira, fn_ref);
13699 ZigType *dest_type = ir_resolve_type(ira, fn_ref, ZigTypeIdInvalid);
1369613700 if (type_is_invalid(dest_type))
1369713701 return ira->codegen->invalid_instruction;
1369813702
......@@ -13817,7 +13821,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source
1381713821static IrInstruction *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
1381813822 Error err;
1381913823 IrInstruction *value = un_op_instruction->value->child;
13820 ZigType *type_entry = ir_resolve_type(ira, value);
13824 ZigType *type_entry = ir_resolve_type(ira, value, ZigTypeIdInvalid);
1382113825 if (type_is_invalid(type_entry))
1382213826 return ira->codegen->invalid_instruction;
1382313827 if ((err = ensure_complete_type(ira->codegen, type_entry)))
......@@ -15300,16 +15304,10 @@ static IrInstruction *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira,
1530015304 IrInstructionPtrTypeChild *ptr_type_child_instruction)
1530115305{
1530215306 IrInstruction *type_value = ptr_type_child_instruction->value->child;
15303 ZigType *type_entry = ir_resolve_type(ira, type_value);
15307 ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdPointer);
1530415308 if (type_is_invalid(type_entry))
1530515309 return ira->codegen->invalid_instruction;
1530615310
15307 if (type_entry->id != ZigTypeIdPointer) {
15308 ir_add_error_node(ira, ptr_type_child_instruction->base.source_node,
15309 buf_sprintf("expected pointer type, found '%s'", buf_ptr(&type_entry->name)));
15310 return ira->codegen->invalid_instruction;
15311 }
15312
1531315311 return ir_const_type(ira, &ptr_type_child_instruction->base, type_entry->data.pointer.child_type);
1531415312}
1531515313
......@@ -15462,7 +15460,7 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira,
1546215460 return ira->codegen->invalid_instruction;
1546315461 }
1546415462
15465 ZigType *child_type = ir_resolve_type(ira, slice_type_instruction->child_type->child);
15463 ZigType *child_type = ir_resolve_type(ira, slice_type_instruction->child_type->child, ZigTypeIdInvalid);
1546615464 if (type_is_invalid(child_type))
1546715465 return ira->codegen->invalid_instruction;
1546815466
......@@ -15545,7 +15543,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs
1554515543 AsmOutput *asm_output = asm_expr->output_list.at(i);
1554615544 if (asm_output->return_type) {
1554715545 output_types[i] = asm_instruction->output_types[i]->child;
15548 return_type = ir_resolve_type(ira, output_types[i]);
15546 return_type = ir_resolve_type(ira, output_types[i], ZigTypeIdInvalid);
1554915547 if (type_is_invalid(return_type))
1555015548 return ira->codegen->invalid_instruction;
1555115549 }
......@@ -15560,7 +15558,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs
1556015558 (input_value->value.type->id == ZigTypeIdComptimeInt ||
1556115559 input_value->value.type->id == ZigTypeIdComptimeFloat)) {
1556215560 ir_add_error_node(ira, input_value->source_node,
15563 buf_sprintf("expected sized integer or sized float, found %s", buf_ptr(&input_value->value.type->name)));
15561 buf_sprintf("expected sized integer or sized float type, found %s", buf_ptr(&input_value->value.type->name)));
1556415562 return ira->codegen->invalid_instruction;
1556515563 }
1556615564
......@@ -15586,7 +15584,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira,
1558615584 return ira->codegen->invalid_instruction;
1558715585
1558815586 IrInstruction *child_type_value = array_type_instruction->child_type->child;
15589 ZigType *child_type = ir_resolve_type(ira, child_type_value);
15587 ZigType *child_type = ir_resolve_type(ira, child_type_value, ZigTypeIdInvalid);
1559015588 if (type_is_invalid(child_type))
1559115589 return ira->codegen->invalid_instruction;
1559215590 switch (child_type->id) {
......@@ -15635,7 +15633,7 @@ static IrInstruction *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrInst
1563515633 if (instruction->payload_type == nullptr) {
1563615634 promise_type = ira->codegen->builtin_types.entry_promise;
1563715635 } else {
15638 ZigType *payload_type = ir_resolve_type(ira, instruction->payload_type->child);
15636 ZigType *payload_type = ir_resolve_type(ira, instruction->payload_type->child, ZigTypeIdInvalid);
1563915637 if (type_is_invalid(payload_type))
1564015638 return ira->codegen->invalid_instruction;
1564115639
......@@ -15650,7 +15648,7 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira,
1565015648{
1565115649 Error err;
1565215650 IrInstruction *type_value = size_of_instruction->type_value->child;
15653 ZigType *type_entry = ir_resolve_type(ira, type_value);
15651 ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid);
1565415652
1565515653 if ((err = ensure_complete_type(ira->codegen, type_entry)))
1565615654 return ira->codegen->invalid_instruction;
......@@ -16485,7 +16483,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
1648516483
1648616484 size_t elem_count = instruction->item_count;
1648716485 if (container_type_value->value.type->id == ZigTypeIdMetaType) {
16488 ZigType *container_type = ir_resolve_type(ira, container_type_value);
16486 ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid);
1648916487 if (type_is_invalid(container_type))
1649016488 return ira->codegen->invalid_instruction;
1649116489
......@@ -16601,7 +16599,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
1660116599
1660216600static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, IrInstructionContainerInitFields *instruction) {
1660316601 IrInstruction *container_type_value = instruction->container_type->child;
16604 ZigType *container_type = ir_resolve_type(ira, container_type_value);
16602 ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid);
1660516603 if (type_is_invalid(container_type))
1660616604 return ira->codegen->invalid_instruction;
1660716605
......@@ -16719,7 +16717,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
1671916717{
1672016718 Error err;
1672116719 IrInstruction *type_value = instruction->type_value->child;
16722 ZigType *container_type = ir_resolve_type(ira, type_value);
16720 ZigType *container_type = ir_resolve_type(ira, type_value, ZigTypeIdStruct);
1672316721 if (type_is_invalid(container_type))
1672416722 return ira->codegen->invalid_instruction;
1672516723
......@@ -16732,12 +16730,6 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
1673216730 if (type_is_invalid(field_ptr->value.type))
1673316731 return ira->codegen->invalid_instruction;
1673416732
16735 if (container_type->id != ZigTypeIdStruct) {
16736 ir_add_error(ira, type_value,
16737 buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name)));
16738 return ira->codegen->invalid_instruction;
16739 }
16740
1674116733 if ((err = ensure_complete_type(ira->codegen, container_type)))
1674216734 return ira->codegen->invalid_instruction;
1674316735
......@@ -16751,7 +16743,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
1675116743
1675216744 if (field_ptr->value.type->id != ZigTypeIdPointer) {
1675316745 ir_add_error(ira, field_ptr,
16754 buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value.type->name)));
16746 buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&field_ptr->value.type->name)));
1675516747 return ira->codegen->invalid_instruction;
1675616748 }
1675716749
......@@ -16810,9 +16802,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
1681016802static TypeStructField *validate_byte_offset(IrAnalyze *ira,
1681116803 IrInstruction *type_value,
1681216804 IrInstruction *field_name_value,
16813 size_t *byte_offset)
16805 size_t *byte_offset)
1681416806{
16815 ZigType *container_type = ir_resolve_type(ira, type_value);
16807 ZigType *container_type = ir_resolve_type(ira, type_value, ZigTypeIdStruct);
1681616808 if (type_is_invalid(container_type))
1681716809 return nullptr;
1681816810
......@@ -16824,12 +16816,6 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira,
1682416816 if (!field_name)
1682516817 return nullptr;
1682616818
16827 if (container_type->id != ZigTypeIdStruct) {
16828 ir_add_error(ira, type_value,
16829 buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name)));
16830 return nullptr;
16831 }
16832
1683316819 TypeStructField *field = find_struct_type_field(container_type, field_name);
1683416820 if (field == nullptr) {
1683516821 ir_add_error(ira, field_name_value,
......@@ -17807,7 +17793,7 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira,
1780717793{
1780817794 Error err;
1780917795 IrInstruction *type_value = instruction->type_value->child;
17810 ZigType *type_entry = ir_resolve_type(ira, type_value);
17796 ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid);
1781117797 if (type_is_invalid(type_entry))
1781217798 return ira->codegen->invalid_instruction;
1781317799
......@@ -17835,7 +17821,7 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira,
1783517821 IrInstructionTypeId *instruction)
1783617822{
1783717823 IrInstruction *type_value = instruction->type_value->child;
17838 ZigType *type_entry = ir_resolve_type(ira, type_value);
17824 ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid);
1783917825 if (type_is_invalid(type_entry))
1784017826 return ira->codegen->invalid_instruction;
1784117827
......@@ -17870,7 +17856,7 @@ static IrInstruction *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ir
1787017856
1787117857static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) {
1787217858 IrInstruction *type_value = instruction->type_value->child;
17873 ZigType *type_entry = ir_resolve_type(ira, type_value);
17859 ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid);
1787417860 if (type_is_invalid(type_entry))
1787517861 return ira->codegen->invalid_instruction;
1787617862
......@@ -18147,7 +18133,7 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction
1814718133
1814818134static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) {
1814918135 IrInstruction *dest_type_value = instruction->dest_type->child;
18150 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
18136 ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid);
1815118137 if (type_is_invalid(dest_type))
1815218138 return ira->codegen->invalid_instruction;
1815318139
......@@ -18200,7 +18186,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct
1820018186}
1820118187
1820218188static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionIntCast *instruction) {
18203 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child);
18189 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid);
1820418190 if (type_is_invalid(dest_type))
1820518191 return ira->codegen->invalid_instruction;
1820618192
......@@ -18233,7 +18219,7 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct
1823318219}
1823418220
1823518221static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionFloatCast *instruction) {
18236 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child);
18222 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid);
1823718223 if (type_is_invalid(dest_type))
1823818224 return ira->codegen->invalid_instruction;
1823918225
......@@ -18273,16 +18259,10 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru
1827318259}
1827418260
1827518261static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructionErrSetCast *instruction) {
18276 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child);
18262 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdErrorSet);
1827718263 if (type_is_invalid(dest_type))
1827818264 return ira->codegen->invalid_instruction;
1827918265
18280 if (dest_type->id != ZigTypeIdErrorSet) {
18281 ir_add_error(ira, instruction->dest_type,
18282 buf_sprintf("expected error set type, found '%s'", buf_ptr(&dest_type->name)));
18283 return ira->codegen->invalid_instruction;
18284 }
18285
1828618266 IrInstruction *target = instruction->target->child;
1828718267 if (type_is_invalid(target->value.type))
1828818268 return ira->codegen->invalid_instruction;
......@@ -18311,7 +18291,7 @@ static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_ali
1831118291static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) {
1831218292 Error err;
1831318293
18314 ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->child);
18294 ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->child, ZigTypeIdInvalid);
1831518295 if (type_is_invalid(dest_child_type))
1831618296 return ira->codegen->invalid_instruction;
1831718297
......@@ -18408,7 +18388,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct
1840818388
1840918389 if (!is_slice(target->value.type)) {
1841018390 ir_add_error(ira, instruction->target,
18411 buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value.type->name)));
18391 buf_sprintf("expected slice type, found '%s'", buf_ptr(&target->value.type->name)));
1841218392 return ira->codegen->invalid_instruction;
1841318393 }
1841418394
......@@ -18427,7 +18407,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct
1842718407}
1842818408
1842918409static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructionIntToFloat *instruction) {
18430 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child);
18410 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid);
1843118411 if (type_is_invalid(dest_type))
1843218412 return ira->codegen->invalid_instruction;
1843318413
......@@ -18445,7 +18425,7 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst
1844518425}
1844618426
1844718427static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) {
18448 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child);
18428 ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child, ZigTypeIdInvalid);
1844918429 if (type_is_invalid(dest_type))
1845018430 return ira->codegen->invalid_instruction;
1845118431
......@@ -18501,7 +18481,7 @@ static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstr
1850118481 return ira->codegen->invalid_instruction;
1850218482
1850318483 if (target->value.type->id != ZigTypeIdBool) {
18504 ir_add_error(ira, instruction->target, buf_sprintf("expected bool, found '%s'",
18484 ir_add_error(ira, instruction->target, buf_sprintf("expected bool type, found '%s'",
1850518485 buf_ptr(&target->value.type->name)));
1850618486 return ira->codegen->invalid_instruction;
1850718487 }
......@@ -19082,7 +19062,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst
1908219062 IrInstruction *container = instruction->container->child;
1908319063 if (type_is_invalid(container->value.type))
1908419064 return ira->codegen->invalid_instruction;
19085 ZigType *container_type = ir_resolve_type(ira, container);
19065 ZigType *container_type = ir_resolve_type(ira, container, ZigTypeIdInvalid);
1908619066
1908719067 if ((err = ensure_complete_type(ira->codegen, container_type)))
1908819068 return ira->codegen->invalid_instruction;
......@@ -19116,7 +19096,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst
1911619096static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) {
1911719097 Error err;
1911819098 IrInstruction *container_type_value = instruction->container_type->child;
19119 ZigType *container_type = ir_resolve_type(ira, container_type_value);
19099 ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid);
1912019100 if (type_is_invalid(container_type))
1912119101 return ira->codegen->invalid_instruction;
1912219102
......@@ -19159,7 +19139,7 @@ static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstr
1915919139static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) {
1916019140 Error err;
1916119141 IrInstruction *container_type_value = instruction->container_type->child;
19162 ZigType *container_type = ir_resolve_type(ira, container_type_value);
19142 ZigType *container_type = ir_resolve_type(ira, container_type_value, ZigTypeIdInvalid);
1916319143 if (type_is_invalid(container_type))
1916419144 return ira->codegen->invalid_instruction;
1916519145
......@@ -19252,7 +19232,7 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct
1925219232 IrInstruction *type_value = instruction->type_value->child;
1925319233 if (type_is_invalid(type_value->value.type))
1925419234 return ira->codegen->invalid_instruction;
19255 ZigType *type_entry = ir_resolve_type(ira, type_value);
19235 ZigType *type_entry = ir_resolve_type(ira, type_value, ZigTypeIdInvalid);
1925619236
1925719237 if ((err = type_resolve(ira->codegen, type_entry, ResolveStatusAlignmentKnown)))
1925819238 return ira->codegen->invalid_instruction;
......@@ -19302,16 +19282,10 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
1930219282 if (type_is_invalid(type_value->value.type))
1930319283 return ira->codegen->invalid_instruction;
1930419284
19305 ZigType *dest_type = ir_resolve_type(ira, type_value);
19285 ZigType *dest_type = ir_resolve_type(ira, type_value, ZigTypeIdInt);
1930619286 if (type_is_invalid(dest_type))
1930719287 return ira->codegen->invalid_instruction;
1930819288
19309 if (dest_type->id != ZigTypeIdInt) {
19310 ir_add_error(ira, type_value,
19311 buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name)));
19312 return ira->codegen->invalid_instruction;
19313 }
19314
1931519289 IrInstruction *op1 = instruction->op1->child;
1931619290 if (type_is_invalid(op1->value.type))
1931719291 return ira->codegen->invalid_instruction;
......@@ -19581,7 +19555,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
1958119555 IrInstruction *param_type_value = instruction->param_types[fn_type_id.next_param_index]->child;
1958219556 if (type_is_invalid(param_type_value->value.type))
1958319557 return ira->codegen->invalid_instruction;
19584 ZigType *param_type = ir_resolve_type(ira, param_type_value);
19558 ZigType *param_type = ir_resolve_type(ira, param_type_value, ZigTypeIdInvalid);
1958519559 switch (type_requires_comptime(ira->codegen, param_type)) {
1958619560 case ReqCompTimeYes:
1958719561 if (!calling_convention_allows_zig_types(fn_type_id.cc)) {
......@@ -19615,7 +19589,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
1961519589 }
1961619590
1961719591 IrInstruction *return_type_value = instruction->return_type->child;
19618 fn_type_id.return_type = ir_resolve_type(ira, return_type_value);
19592 fn_type_id.return_type = ir_resolve_type(ira, return_type_value, ZigTypeIdInvalid);
1961919593 if (type_is_invalid(fn_type_id.return_type))
1962019594 return ira->codegen->invalid_instruction;
1962119595 if (fn_type_id.return_type->id == ZigTypeIdOpaque) {
......@@ -19631,7 +19605,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
1963119605 return ira->codegen->invalid_instruction;
1963219606 }
1963319607 IrInstruction *async_allocator_type_value = instruction->async_allocator_type_value->child;
19634 fn_type_id.async_allocator_type = ir_resolve_type(ira, async_allocator_type_value);
19608 fn_type_id.async_allocator_type = ir_resolve_type(ira, async_allocator_type_value, ZigTypeIdInvalid);
1963519609 if (type_is_invalid(fn_type_id.async_allocator_type))
1963619610 return ira->codegen->invalid_instruction;
1963719611 }
......@@ -19939,7 +19913,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
1993919913 result_type = get_slice_type(ira->codegen, result_ptr_type);
1994019914 } else {
1994119915 ir_add_error(ira, target,
19942 buf_sprintf("expected pointer or slice, found '%s'", buf_ptr(&target_type->name)));
19916 buf_sprintf("expected pointer or slice type, found '%s'", buf_ptr(&target_type->name)));
1994319917 return ira->codegen->invalid_instruction;
1994419918 }
1994519919
......@@ -19985,13 +19959,13 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_
1998519959 // validate src_type and dest_type.
1998619960
1998719961 if (get_src_ptr_type(src_type) == nullptr) {
19988 ir_add_error(ira, ptr, buf_sprintf("expected pointer, found '%s'", buf_ptr(&src_type->name)));
19962 ir_add_error(ira, ptr, buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&src_type->name)));
1998919963 return ira->codegen->invalid_instruction;
1999019964 }
1999119965
1999219966 if (get_src_ptr_type(dest_type) == nullptr) {
1999319967 ir_add_error(ira, dest_type_src,
19994 buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name)));
19968 buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&dest_type->name)));
1999519969 return ira->codegen->invalid_instruction;
1999619970 }
1999719971
......@@ -20059,7 +20033,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_
2005920033
2006020034static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCast *instruction) {
2006120035 IrInstruction *dest_type_value = instruction->dest_type->child;
20062 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
20036 ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid);
2006320037 if (type_is_invalid(dest_type))
2006420038 return ira->codegen->invalid_instruction;
2006520039
......@@ -20255,7 +20229,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou
2025520229static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBitCast *instruction) {
2025620230 Error err;
2025720231 IrInstruction *dest_type_value = instruction->dest_type->child;
20258 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
20232 ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid);
2025920233 if (type_is_invalid(dest_type))
2026020234 return ira->codegen->invalid_instruction;
2026120235
......@@ -20352,13 +20326,13 @@ static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruct
2035220326static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) {
2035320327 Error err;
2035420328 IrInstruction *dest_type_value = instruction->dest_type->child;
20355 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
20329 ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdInvalid);
2035620330 if (type_is_invalid(dest_type))
2035720331 return ira->codegen->invalid_instruction;
2035820332
2035920333 // We explicitly check for the size, so we can use get_src_ptr_type
2036020334 if (get_src_ptr_type(dest_type) == nullptr) {
20361 ir_add_error(ira, dest_type_value, buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name)));
20335 ir_add_error(ira, dest_type_value, buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&dest_type->name)));
2036220336 return ira->codegen->invalid_instruction;
2036320337 }
2036420338
......@@ -20461,7 +20435,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru
2046120435 // We check size explicitly so we can use get_src_ptr_type here.
2046220436 if (get_src_ptr_type(target->value.type) == nullptr) {
2046320437 ir_add_error(ira, target,
20464 buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value.type->name)));
20438 buf_sprintf("expected Pointer type, found '%s'", buf_ptr(&target->value.type->name)));
2046520439 return ira->codegen->invalid_instruction;
2046620440 }
2046720441
......@@ -20492,7 +20466,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru
2049220466
2049320467static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) {
2049420468 Error err;
20495 ZigType *child_type = ir_resolve_type(ira, instruction->child_type->child);
20469 ZigType *child_type = ir_resolve_type(ira, instruction->child_type->child, ZigTypeIdInvalid);
2049620470 if (type_is_invalid(child_type))
2049720471 return ira->codegen->invalid_instruction;
2049820472
......@@ -20591,7 +20565,7 @@ static IrInstruction *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrI
2059120565
2059220566static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) {
2059320567 IrInstruction *fn_type_inst = instruction->fn_type->child;
20594 ZigType *fn_type = ir_resolve_type(ira, fn_type_inst);
20568 ZigType *fn_type = ir_resolve_type(ira, fn_type_inst, ZigTypeIdFn);
2059520569 if (type_is_invalid(fn_type))
2059620570 return ira->codegen->invalid_instruction;
2059720571
......@@ -20600,11 +20574,6 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct
2060020574 if (!ir_resolve_usize(ira, arg_index_inst, &arg_index))
2060120575 return ira->codegen->invalid_instruction;
2060220576
20603 if (fn_type->id != ZigTypeIdFn) {
20604 ir_add_error(ira, fn_type_inst, buf_sprintf("expected function, found '%s'", buf_ptr(&fn_type->name)));
20605 return ira->codegen->invalid_instruction;
20606 }
20607
2060820577 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
2060920578 if (arg_index >= fn_type_id->param_count) {
2061020579 ir_add_error(ira, arg_index_inst,
......@@ -20629,7 +20598,7 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct
2062920598static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) {
2063020599 Error err;
2063120600 IrInstruction *target_inst = instruction->target->child;
20632 ZigType *enum_type = ir_resolve_type(ira, target_inst);
20601 ZigType *enum_type = ir_resolve_type(ira, target_inst, ZigTypeIdInvalid);
2063320602 if (type_is_invalid(enum_type))
2063420603 return ira->codegen->invalid_instruction;
2063520604
......@@ -20654,7 +20623,7 @@ static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstruct
2065420623 return ira->codegen->invalid_instruction;
2065520624 }
2065620625 } else {
20657 ir_add_error(ira, target_inst, buf_sprintf("expected enum or union, found '%s'",
20626 ir_add_error(ira, target_inst, buf_sprintf("expected enum or union type, found '%s'",
2065820627 buf_ptr(&enum_type->name)));
2065920628 return ira->codegen->invalid_instruction;
2066020629 }
......@@ -20808,7 +20777,7 @@ static IrInstruction *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInst
2080820777 if (coro_handle->value.type->id != ZigTypeIdPromise ||
2080920778 coro_handle->value.type->data.promise.result_type == nullptr)
2081020779 {
20811 ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T, found '%s'",
20780 ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T type, found '%s'",
2081220781 buf_ptr(&coro_handle->value.type->name)));
2081320782 return ira->codegen->invalid_instruction;
2081420783 }
......@@ -20839,7 +20808,7 @@ static IrInstruction *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira, I
2083920808}
2084020809
2084120810static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op) {
20842 ZigType *operand_type = ir_resolve_type(ira, op);
20811 ZigType *operand_type = ir_resolve_type(ira, op, ZigTypeIdInvalid);
2084320812 if (type_is_invalid(operand_type))
2084420813 return ira->codegen->builtin_types.entry_invalid;
2084520814
......@@ -20969,12 +20938,12 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr
2096920938}
2097020939
2097120940static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, IrInstructionPromiseResultType *instruction) {
20972 ZigType *promise_type = ir_resolve_type(ira, instruction->promise_type->child);
20941 ZigType *promise_type = ir_resolve_type(ira, instruction->promise_type->child, ZigTypeIdInvalid);
2097320942 if (type_is_invalid(promise_type))
2097420943 return ira->codegen->invalid_instruction;
2097520944
2097620945 if (promise_type->id != ZigTypeIdPromise || promise_type->data.promise.result_type == nullptr) {
20977 ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T, found '%s'",
20946 ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T type, found '%s'",
2097820947 buf_ptr(&promise_type->name)));
2097920948 return ira->codegen->invalid_instruction;
2098020949 }
......@@ -20983,7 +20952,7 @@ static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira,
2098320952}
2098420953
2098520954static IrInstruction *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, IrInstructionAwaitBookkeeping *instruction) {
20986 ZigType *promise_result_type = ir_resolve_type(ira, instruction->promise_result_type->child);
20955 ZigType *promise_result_type = ir_resolve_type(ira, instruction->promise_result_type->child, ZigTypeIdInvalid);
2098720956 if (type_is_invalid(promise_result_type))
2098820957 return ira->codegen->invalid_instruction;
2098920958
......@@ -21046,7 +21015,7 @@ static IrInstruction *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *i
2104621015}
2104721016
2104821017static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *instruction) {
21049 ZigType *float_type = ir_resolve_type(ira, instruction->type->child);
21018 ZigType *float_type = ir_resolve_type(ira, instruction->type->child, ZigTypeIdInvalid);
2105021019 if (type_is_invalid(float_type))
2105121020 return ira->codegen->invalid_instruction;
2105221021
......@@ -21113,7 +21082,7 @@ static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionS
2111321082}
2111421083
2111521084static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstructionBswap *instruction) {
21116 ZigType *int_type = ir_resolve_type(ira, instruction->type->child);
21085 ZigType *int_type = ir_resolve_type(ira, instruction->type->child, ZigTypeIdInvalid);
2111721086 if (type_is_invalid(int_type))
2111821087 return ira->codegen->invalid_instruction;
2111921088
......@@ -21169,7 +21138,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction
2116921138}
2117021139
2117121140static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstructionBitReverse *instruction) {
21172 ZigType *int_type = ir_resolve_type(ira, instruction->type->child);
21141 ZigType *int_type = ir_resolve_type(ira, instruction->type->child, ZigTypeIdInvalid);
2117321142 if (type_is_invalid(int_type))
2117421143 return ira->codegen->invalid_instruction;
2117521144
......@@ -21240,7 +21209,7 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr
2124021209
2124121210 if (target->value.type->id != ZigTypeIdEnum) {
2124221211 ir_add_error(ira, instruction->target,
21243 buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value.type->name)));
21212 buf_sprintf("expected enum type, found '%s'", buf_ptr(&target->value.type->name)));
2124421213 return ira->codegen->invalid_instruction;
2124521214 }
2124621215
......@@ -21255,16 +21224,10 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr
2125521224static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) {
2125621225 Error err;
2125721226 IrInstruction *dest_type_value = instruction->dest_type->child;
21258 ZigType *dest_type = ir_resolve_type(ira, dest_type_value);
21227 ZigType *dest_type = ir_resolve_type(ira, dest_type_value, ZigTypeIdEnum);
2125921228 if (type_is_invalid(dest_type))
2126021229 return ira->codegen->invalid_instruction;
2126121230
21262 if (dest_type->id != ZigTypeIdEnum) {
21263 ir_add_error(ira, instruction->dest_type,
21264 buf_sprintf("expected enum, found type '%s'", buf_ptr(&dest_type->name)));
21265 return ira->codegen->invalid_instruction;
21266 }
21267
2126821231 if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown)))
2126921232 return ira->codegen->invalid_instruction;
2127021233
src/parser.cpp+29-6
......@@ -122,19 +122,37 @@ static AstNode *ast_parse_container_decl_type(ParseContext *pc);
122122static AstNode *ast_parse_byte_align(ParseContext *pc);
123123
124124ATTRIBUTE_PRINTF(3, 4)
125ATTRIBUTE_NORETURN
126static void ast_error(ParseContext *pc, Token *token, const char *format, ...) {
125static ErrorMsg *ast_error(ParseContext *pc, Token *token, const char *format, ...) {
127126 va_list ap;
128127 va_start(ap, format);
129128 Buf *msg = buf_vprintf(format, ap);
130129 va_end(ap);
131130
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_NORETURN
141static void ast_error_exit(ParseContext *pc, Token *token, ErrorMsg *note, const char *format, ...) {
142 va_list ap;
143 va_start(ap, format);
144 Buf *msg = buf_vprintf(format, ap);
145 va_end(ap);
132146
133147 ErrorMsg *err = err_msg_create_with_line(pc->owner->path, token->start_line, token->start_column,
134148 pc->owner->source_code, pc->owner->line_offsets, msg);
135149 err->line_start = token->start_line;
136150 err->column_start = token->start_column;
137151
152 if (note) {
153 err->notes.append(note);
154 }
155
138156 print_err_msg(err, pc->err_color);
139157 exit(EXIT_FAILURE);
140158}
......@@ -164,7 +182,7 @@ static Buf ast_token_str(Buf *input, Token *token) {
164182ATTRIBUTE_NORETURN
165183static void ast_invalid_token_error(ParseContext *pc, Token *token) {
166184 Buf token_value = ast_token_str(pc->buf, token);
167 ast_error(pc, token, "invalid token: '%s'", buf_ptr(&token_value));
185 ast_error_exit(pc, token, NULL, "invalid token: '%s'", buf_ptr(&token_value));
168186}
169187
170188static AstNode *ast_create_node_no_line_info(ParseContext *pc, NodeType type) {
......@@ -214,8 +232,13 @@ static Token *eat_token_if(ParseContext *pc, TokenId id) {
214232
215233static Token *expect_token(ParseContext *pc, TokenId id) {
216234 Token *res = eat_token(pc);
217 if (res->id != id)
218 ast_error(pc, res, "expected token '%s', found '%s'", token_name(id), token_name(res->id));
235 if (res->id != id) {
236 ErrorMsg *note = NULL;
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 }
219242
220243 return res;
221244}
......@@ -837,7 +860,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
837860 if (param_decl->data.param_decl.is_var_args)
838861 res->data.fn_proto.is_var_args = true;
839862 if (i != params.length - 1 && res->data.fn_proto.is_var_args)
840 ast_error(pc, first, "Function prototype have varargs as a none last paramter.");
863 ast_error_exit(pc, first, NULL, "Function prototype have varargs as a none last paramter.");
841864 }
842865 return res;
843866}
src/tokenizer.cpp+12
......@@ -199,6 +199,7 @@ enum TokenizeState {
199199 TokenizeStateSawDash,
200200 TokenizeStateSawMinusPercent,
201201 TokenizeStateSawAmpersand,
202 TokenizeStateSawAmpersandAmpersand,
202203 TokenizeStateSawCaret,
203204 TokenizeStateSawBar,
204205 TokenizeStateSawBarBar,
......@@ -891,6 +892,10 @@ void tokenize(Buf *buf, Tokenization *out) {
891892 end_token(&t);
892893 t.state = TokenizeStateStart;
893894 break;
895 case '&':
896 set_token_id(&t, t.cur_tok, TokenIdAmpersandAmpersand);
897 t.state = TokenizeStateSawAmpersandAmpersand;
898 break;
894899 default:
895900 t.pos -= 1;
896901 end_token(&t);
......@@ -898,6 +903,11 @@ void tokenize(Buf *buf, Tokenization *out) {
898903 continue;
899904 }
900905 break;
906 case TokenizeStateSawAmpersandAmpersand:
907 t.pos -= 1;
908 end_token(&t);
909 t.state = TokenizeStateStart;
910 continue;
901911 case TokenizeStateSawCaret:
902912 switch (c) {
903913 case '=':
......@@ -1468,6 +1478,7 @@ void tokenize(Buf *buf, Tokenization *out) {
14681478 case TokenizeStateSawPlus:
14691479 case TokenizeStateSawDash:
14701480 case TokenizeStateSawAmpersand:
1481 case TokenizeStateSawAmpersandAmpersand:
14711482 case TokenizeStateSawCaret:
14721483 case TokenizeStateSawBar:
14731484 case TokenizeStateSawEq:
......@@ -1515,6 +1526,7 @@ void tokenize(Buf *buf, Tokenization *out) {
15151526const char * token_name(TokenId id) {
15161527 switch (id) {
15171528 case TokenIdAmpersand: return "&";
1529 case TokenIdAmpersandAmpersand: return "&&";
15181530 case TokenIdArrow: return "->";
15191531 case TokenIdAtSign: return "@";
15201532 case TokenIdBang: return "!";
src/tokenizer.hpp+1
......@@ -14,6 +14,7 @@
1414
1515enum TokenId {
1616 TokenIdAmpersand,
17 TokenIdAmpersandAmpersand,
1718 TokenIdArrow,
1819 TokenIdAtSign,
1920 TokenIdBang,
test/compile_errors.zig+88-57
......@@ -1,6 +1,36 @@
11const tests = @import("tests.zig");
22
33pub fn addCases(cases: *tests.CompileErrorContext) void {
4 cases.add(
5 "Use of && in place of `and`",
6 \\export fn entry() void {
7 \\ if (true && false) return;
8 \\}
9 ,
10 ".tmp_source.zig:2:14: error: expected token ')', found '&&'",
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 \\}
19 ,
20 ".tmp_source.zig:2:9: error: expected ErrorSet type, found 'comptime_int'",
21 ".tmp_source.zig:2:11: note: did you mean to use `or`?",
22 );
23
24 cases.add(
25 "Use of || in place of `or` (using booleans)",
26 \\export fn entry() void {
27 \\ if (true || false) return;
28 \\}
29 ,
30 ".tmp_source.zig:2:9: error: expected ErrorSet type, found 'bool'",
31 ".tmp_source.zig:2:14: note: did you mean to use `or`?",
32 );
33
434 cases.add(
535 "compile log a pointer to an opaque value",
636 \\export fn entry() void {
......@@ -68,7 +98,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6898 \\ do_the_thing(bar);
6999 \\}
70100 ,
71 ".tmp_source.zig:4:18: error: expected type 'fn(i32) void', found 'fn(bool) void",
101 ".tmp_source.zig:4:18: error: expected 'fn(i32) void' type, found 'fn(bool) void",
72102 ".tmp_source.zig:4:18: note: parameter 0: 'bool' cannot cast into 'i32'",
73103 );
74104
......@@ -104,7 +134,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
104134 ,
105135 ".tmp_source.zig:3:31: error: integer value 300 cannot be implicitly casted to type 'u8'",
106136 ".tmp_source.zig:7:22: error: integer value 300 cannot be implicitly casted to type 'u8'",
107 ".tmp_source.zig:11:20: error: expected type 'u8', found 'u16'",
137 ".tmp_source.zig:11:20: error: expected 'u8' type, found 'u16'",
108138 );
109139
110140 cases.add(
......@@ -124,7 +154,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
124154 \\
125155 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
126156 ,
127 ".tmp_source.zig:2:14: error: expected type 'f32', found 'f64'",
157 ".tmp_source.zig:2:14: error: expected 'f32' type, found 'f64'",
128158 );
129159
130160 cases.add(
......@@ -172,7 +202,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
172202 \\ var ptr2: *c_void = &b;
173203 \\}
174204 ,
175 ".tmp_source.zig:5:26: error: expected type '*c_void', found '**u32'",
205 ".tmp_source.zig:5:26: error: expected '*c_void' type, found '**u32'",
176206 );
177207
178208 cases.add(
......@@ -222,7 +252,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
222252 \\ const sliceA: []u8 = &buffer;
223253 \\}
224254 ,
225 ".tmp_source.zig:3:27: error: expected type '[]u8', found '*const [1]u8'",
255 ".tmp_source.zig:3:27: error: expected '[]u8' type, found '*const [1]u8'",
226256 );
227257
228258 cases.add(
......@@ -267,8 +297,9 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
267297 \\ const Errors = error{} || u16;
268298 \\}
269299 ,
270 ".tmp_source.zig:2:20: error: expected error set type, found 'u8'",
271 ".tmp_source.zig:5:31: error: expected error set type, found 'u16'",
300 ".tmp_source.zig:2:20: error: expected ErrorSet type, found 'u8'",
301 ".tmp_source.zig:2:23: note: did you mean to use `or`?",
302 ".tmp_source.zig:5:31: error: expected ErrorSet type, found 'u16'",
272303 );
273304
274305 cases.add(
......@@ -763,7 +794,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
763794 \\
764795 \\fn bar(x: *b.Foo) void {}
765796 ,
766 ".tmp_source.zig:6:10: error: expected type '*Foo', found '*Foo'",
797 ".tmp_source.zig:6:10: error: expected '*Foo' type, found '*Foo'",
767798 ".tmp_source.zig:6:10: note: pointer type child 'Foo' cannot cast into pointer type child 'Foo'",
768799 "a.zig:1:17: note: Foo declared here",
769800 "b.zig:1:17: note: Foo declared here",
......@@ -833,7 +864,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
833864 \\ var y = p.*;
834865 \\}
835866 ,
836 ".tmp_source.zig:4:23: error: expected type '*?*i32', found '**i32'",
867 ".tmp_source.zig:4:23: error: expected '*?*i32' type, found '**i32'",
837868 );
838869
839870 cases.add(
......@@ -842,7 +873,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
842873 \\ const x: [*]const bool = true;
843874 \\}
844875 ,
845 ".tmp_source.zig:2:30: error: expected type '[*]const bool', found 'bool'",
876 ".tmp_source.zig:2:30: error: expected '[*]const bool' type, found 'bool'",
846877 );
847878
848879 cases.add(
......@@ -887,7 +918,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
887918 \\ var rule_set = try Foo.init();
888919 \\}
889920 ,
890 ".tmp_source.zig:2:13: error: expected type 'i32', found 'type'",
921 ".tmp_source.zig:2:13: error: expected 'i32' type, found 'type'",
891922 );
892923
893924 cases.add(
......@@ -921,7 +952,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
921952 \\ return null;
922953 \\}
923954 ,
924 ".tmp_source.zig:5:34: error: expected type '?NextError!i32', found '?OtherError!i32'",
955 ".tmp_source.zig:5:34: error: expected '?NextError!i32' type, found '?OtherError!i32'",
925956 ".tmp_source.zig:5:34: note: optional type child 'OtherError!i32' cannot cast into optional type child 'NextError!i32'",
926957 ".tmp_source.zig:5:34: note: error set 'OtherError' cannot cast into error set 'NextError'",
927958 ".tmp_source.zig:2:26: note: 'error.OutOfMemory' not a member of destination error set",
......@@ -991,7 +1022,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
9911022 \\ @panic(e);
9921023 \\}
9931024 ,
994 ".tmp_source.zig:3:12: error: expected type '[]const u8', found 'error{Foo}'",
1025 ".tmp_source.zig:3:12: error: expected '[]const u8' type, found 'error{Foo}'",
9951026 );
9961027
9971028 cases.add(
......@@ -1019,7 +1050,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
10191050 \\ return error.ShouldBeCompileError;
10201051 \\}
10211052 ,
1022 ".tmp_source.zig:6:17: error: expected type 'void', found 'error{ShouldBeCompileError}'",
1053 ".tmp_source.zig:6:17: error: expected 'void' type, found 'error{ShouldBeCompileError}'",
10231054 );
10241055
10251056 cases.add(
......@@ -1062,7 +1093,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
10621093 \\ a(c);
10631094 \\}
10641095 ,
1065 ".tmp_source.zig:8:7: error: expected type 'fn(*const u8) void', found 'fn(u8) void'",
1096 ".tmp_source.zig:8:7: error: expected 'fn(*const u8) void' type, found 'fn(u8) void'",
10661097 );
10671098
10681099 cases.add(
......@@ -1144,7 +1175,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
11441175 \\ E.One => {},
11451176 \\ }
11461177 \\}
1147 , ".tmp_source.zig:9:10: error: expected type 'usize', found 'E'");
1178 , ".tmp_source.zig:9:10: error: expected 'usize' type, found 'E'");
11481179
11491180 cases.add(
11501181 "range operator in switch used on error set",
......@@ -1190,7 +1221,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
11901221 \\ const z = i32!i32;
11911222 \\}
11921223 ,
1193 ".tmp_source.zig:2:15: error: expected error set type, found type 'i32'",
1224 ".tmp_source.zig:2:15: error: expected ErrorSet type, found 'i32'",
11941225 );
11951226
11961227 cases.add(
......@@ -1240,7 +1271,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
12401271 \\ return error.B;
12411272 \\}
12421273 ,
1243 ".tmp_source.zig:3:35: error: expected type 'SmallErrorSet!i32', found 'anyerror!i32'",
1274 ".tmp_source.zig:3:35: error: expected 'SmallErrorSet!i32' type, found 'anyerror!i32'",
12441275 ".tmp_source.zig:3:35: note: error set 'anyerror' cannot cast into error set 'SmallErrorSet'",
12451276 ".tmp_source.zig:3:35: note: cannot cast global error set into smaller set",
12461277 );
......@@ -1255,7 +1286,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
12551286 \\ return error.B;
12561287 \\}
12571288 ,
1258 ".tmp_source.zig:3:31: error: expected type 'SmallErrorSet', found 'anyerror'",
1289 ".tmp_source.zig:3:31: error: expected 'SmallErrorSet' type, found 'anyerror'",
12591290 ".tmp_source.zig:3:31: note: cannot cast global error set into smaller set",
12601291 );
12611292
......@@ -1282,7 +1313,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
12821313 \\ var x: Set2 = set1;
12831314 \\}
12841315 ,
1285 ".tmp_source.zig:7:19: error: expected type 'Set2', found 'Set1'",
1316 ".tmp_source.zig:7:19: error: expected 'Set2' type, found 'Set1'",
12861317 ".tmp_source.zig:1:23: note: 'error.B' not a member of destination error set",
12871318 );
12881319
......@@ -1822,7 +1853,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
18221853 \\fn a() noreturn {return;}
18231854 \\export fn entry() void { a(); }
18241855 ,
1825 ".tmp_source.zig:1:18: error: expected type 'noreturn', found 'void'",
1856 ".tmp_source.zig:1:18: error: expected 'noreturn' type, found 'void'",
18261857 );
18271858
18281859 cases.add(
......@@ -1830,7 +1861,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
18301861 \\fn a() i32 {}
18311862 \\export fn entry() void { _ = a(); }
18321863 ,
1833 ".tmp_source.zig:1:12: error: expected type 'i32', found 'void'",
1864 ".tmp_source.zig:1:12: error: expected 'i32' type, found 'void'",
18341865 );
18351866
18361867 cases.add(
......@@ -1936,7 +1967,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
19361967 \\ return a;
19371968 \\}
19381969 ,
1939 ".tmp_source.zig:3:12: error: expected type 'i32', found '[*]const u8'",
1970 ".tmp_source.zig:3:12: error: expected 'i32' type, found '[*]const u8'",
19401971 );
19411972
19421973 cases.add(
......@@ -1945,7 +1976,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
19451976 \\ if (0) {}
19461977 \\}
19471978 ,
1948 ".tmp_source.zig:2:9: error: expected type 'bool', found 'comptime_int'",
1979 ".tmp_source.zig:2:9: error: expected 'bool' type, found 'comptime_int'",
19491980 );
19501981
19511982 cases.add(
......@@ -2040,8 +2071,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
20402071 \\ array[bad] = array[bad];
20412072 \\}
20422073 ,
2043 ".tmp_source.zig:4:11: error: expected type 'usize', found 'bool'",
2044 ".tmp_source.zig:4:24: error: expected type 'usize', found 'bool'",
2074 ".tmp_source.zig:4:11: error: expected 'usize' type, found 'bool'",
2075 ".tmp_source.zig:4:24: error: expected 'usize' type, found 'bool'",
20452076 );
20462077
20472078 cases.add(
......@@ -2455,7 +2486,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
24552486 \\fn foo() *const i32 { return y; }
24562487 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
24572488 ,
2458 ".tmp_source.zig:3:30: error: expected type '*const i32', found '*const comptime_int'",
2489 ".tmp_source.zig:3:30: error: expected '*const i32' type, found '*const comptime_int'",
24592490 );
24602491
24612492 cases.add(
......@@ -2533,7 +2564,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
25332564 \\fn c() i32 {return 2;}
25342565 \\export fn entry() usize { return @sizeOf(@typeOf(fns)); }
25352566 ,
2536 ".tmp_source.zig:1:27: error: expected type 'fn() void', found 'fn() i32'",
2567 ".tmp_source.zig:1:27: error: expected 'fn() void' type, found 'fn() i32'",
25372568 );
25382569
25392570 cases.add(
......@@ -2545,7 +2576,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
25452576 \\
25462577 \\export fn entry() usize { return @sizeOf(@typeOf(fns)); }
25472578 ,
2548 ".tmp_source.zig:1:36: error: expected type 'fn(i32) i32', found 'extern fn(i32) i32'",
2579 ".tmp_source.zig:1:36: error: expected 'fn(i32) i32' type, found 'extern fn(i32) i32'",
25492580 );
25502581
25512582 cases.add(
......@@ -2649,7 +2680,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
26492680 \\
26502681 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
26512682 ,
2652 ".tmp_source.zig:1:16: error: expected type '*u8', found '(null)'",
2683 ".tmp_source.zig:1:16: error: expected '*u8' type, found '(null)'",
26532684 );
26542685
26552686 cases.add(
......@@ -3289,7 +3320,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
32893320 \\}
32903321 \\fn something() anyerror!void { }
32913322 ,
3292 ".tmp_source.zig:2:5: error: expected type 'void', found 'anyerror'",
3323 ".tmp_source.zig:2:5: error: expected 'void' type, found 'anyerror'",
32933324 ".tmp_source.zig:1:15: note: return type declared here",
32943325 );
32953326
......@@ -3468,7 +3499,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
34683499 \\ derp.init();
34693500 \\}
34703501 ,
3471 ".tmp_source.zig:14:5: error: expected type 'i32', found 'Foo'",
3502 ".tmp_source.zig:14:5: error: expected 'i32' type, found 'Foo'",
34723503 );
34733504
34743505 cases.add(
......@@ -3498,7 +3529,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
34983529 \\ x.init();
34993530 \\}
35003531 ,
3501 ".tmp_source.zig:23:5: error: expected type '*Allocator', found '*List'",
3532 ".tmp_source.zig:23:5: error: expected '*Allocator' type, found '*List'",
35023533 );
35033534
35043535 cases.add(
......@@ -3670,7 +3701,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
36703701 \\
36713702 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
36723703 ,
3673 ".tmp_source.zig:8:26: error: expected type '*const u3', found '*align(:3:1) const u3'",
3704 ".tmp_source.zig:8:26: error: expected '*const u3' type, found '*align(:3:1) const u3'",
36743705 );
36753706
36763707 cases.add(
......@@ -3799,7 +3830,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
37993830 \\
38003831 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
38013832 ,
3802 ".tmp_source.zig:4:19: error: expected type '*[]const u8', found '*const []const u8'",
3833 ".tmp_source.zig:4:19: error: expected '*[]const u8' type, found '*const []const u8'",
38033834 );
38043835
38053836 cases.addCase(x: {
......@@ -3831,7 +3862,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38313862 \\ foo(global_array);
38323863 \\}
38333864 ,
3834 ".tmp_source.zig:4:9: error: expected type '[]i32', found '[10]i32'",
3865 ".tmp_source.zig:4:9: error: expected '[]i32' type, found '[10]i32'",
38353866 );
38363867
38373868 cases.add(
......@@ -3840,7 +3871,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38403871 \\ return @ptrCast(usize, a);
38413872 \\}
38423873 ,
3843 ".tmp_source.zig:2:21: error: expected pointer, found 'usize'",
3874 ".tmp_source.zig:2:21: error: expected Pointer type, found 'usize'",
38443875 );
38453876
38463877 cases.add(
......@@ -3887,7 +3918,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38873918 \\ return @fieldParentPtr(Foo, "a", a);
38883919 \\}
38893920 ,
3890 ".tmp_source.zig:3:28: error: expected struct type, found 'i32'",
3921 ".tmp_source.zig:3:28: error: expected Struct type, found 'i32'",
38913922 );
38923923
38933924 cases.add(
......@@ -3911,7 +3942,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
39113942 \\ return @fieldParentPtr(Foo, "a", a);
39123943 \\}
39133944 ,
3914 ".tmp_source.zig:5:38: error: expected pointer, found 'i32'",
3945 ".tmp_source.zig:5:38: error: expected Pointer type, found 'i32'",
39153946 );
39163947
39173948 cases.add(
......@@ -3952,7 +3983,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
39523983 \\ return @byteOffsetOf(Foo, "a",);
39533984 \\}
39543985 ,
3955 ".tmp_source.zig:3:26: error: expected struct type, found 'i32'",
3986 ".tmp_source.zig:3:26: error: expected Struct type, found 'i32'",
39563987 );
39573988
39583989 cases.add(
......@@ -4066,7 +4097,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
40664097 \\}
40674098 \\fn bar() ?i32 { return 1; }
40684099 ,
4069 ".tmp_source.zig:2:15: error: expected type 'bool', found '?i32'",
4100 ".tmp_source.zig:2:15: error: expected 'bool' type, found '?i32'",
40704101 );
40714102
40724103 cases.add(
......@@ -4076,7 +4107,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
40764107 \\}
40774108 \\fn bar() anyerror!i32 { return 1; }
40784109 ,
4079 ".tmp_source.zig:2:15: error: expected type 'bool', found 'anyerror!i32'",
4110 ".tmp_source.zig:2:15: error: expected 'bool' type, found 'anyerror!i32'",
40804111 );
40814112
40824113 cases.add(
......@@ -4337,7 +4368,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
43374368 \\ return @ptrToInt(x);
43384369 \\}
43394370 ,
4340 ".tmp_source.zig:2:22: error: expected pointer, found 'i32'",
4371 ".tmp_source.zig:2:22: error: expected Pointer type, found 'i32'",
43414372 );
43424373
43434374 cases.add(
......@@ -4373,7 +4404,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
43734404 \\ return x << y;
43744405 \\}
43754406 ,
4376 ".tmp_source.zig:2:17: error: expected type 'u3', found 'u8'",
4407 ".tmp_source.zig:2:17: error: expected 'u3' type, found 'u8'",
43774408 );
43784409
43794410 cases.add(
......@@ -4402,7 +4433,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
44024433 \\ x.* += 1;
44034434 \\}
44044435 ,
4405 ".tmp_source.zig:8:13: error: expected type '*u32', found '*align(1) u32'",
4436 ".tmp_source.zig:8:13: error: expected '*u32' type, found '*align(1) u32'",
44064437 );
44074438
44084439 cases.add(
......@@ -4446,7 +4477,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
44464477 \\ @alignCast(4, u32(3));
44474478 \\}
44484479 ,
4449 ".tmp_source.zig:2:22: error: expected pointer or slice, found 'u32'",
4480 ".tmp_source.zig:2:22: error: expected pointer or slice type, found 'u32'",
44504481 );
44514482
44524483 cases.add(
......@@ -4459,7 +4490,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
44594490 \\}
44604491 \\fn alignedSmall() align(4) i32 { return 1234; }
44614492 ,
4462 ".tmp_source.zig:2:35: error: expected type 'fn() align(8) i32', found 'fn() align(4) i32'",
4493 ".tmp_source.zig:2:35: error: expected 'fn() align(8) i32' type, found 'fn() align(4) i32'",
44634494 );
44644495
44654496 cases.add(
......@@ -4471,7 +4502,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
44714502 \\ return x == 5678;
44724503 \\}
44734504 ,
4474 ".tmp_source.zig:4:32: error: expected type '*i32', found '*align(1) i32'",
4505 ".tmp_source.zig:4:32: error: expected '*i32' type, found '*align(1) i32'",
44754506 );
44764507
44774508 cases.add(
......@@ -4506,7 +4537,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
45064537 \\ bar(@ptrCast(*c_void, &x));
45074538 \\}
45084539 ,
4509 ".tmp_source.zig:5:9: error: expected type '*Derp', found '*c_void'",
4540 ".tmp_source.zig:5:9: error: expected '*Derp' type, found '*c_void'",
45104541 );
45114542
45124543 cases.add(
......@@ -4552,7 +4583,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
45524583 \\ while (!@cmpxchgWeak(i32, &x, 1234, 5678, u32(1234), u32(1234))) {}
45534584 \\}
45544585 ,
4555 ".tmp_source.zig:3:50: error: expected type 'AtomicOrder', found 'u32'",
4586 ".tmp_source.zig:3:50: error: expected 'AtomicOrder' type, found 'u32'",
45564587 );
45574588
45584589 cases.add(
......@@ -4562,7 +4593,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
45624593 \\ @export("entry", entry, u32(1234));
45634594 \\}
45644595 ,
4565 ".tmp_source.zig:3:32: error: expected type 'GlobalLinkage', found 'u32'",
4596 ".tmp_source.zig:3:32: error: expected 'GlobalLinkage' type, found 'u32'",
45664597 );
45674598
45684599 cases.add(
......@@ -4739,7 +4770,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
47394770 \\ _ = @ArgType(i32, 3);
47404771 \\}
47414772 ,
4742 ".tmp_source.zig:2:18: error: expected function, found 'i32'",
4773 ".tmp_source.zig:2:18: error: expected Fn type, found 'i32'",
47434774 );
47444775
47454776 cases.add(
......@@ -4837,7 +4868,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
48374868 \\}
48384869 \\pub extern fn foo(format: *const u8, ...) void;
48394870 ,
4840 ".tmp_source.zig:2:9: error: expected type '*const u8', found '[5]u8'",
4871 ".tmp_source.zig:2:9: error: expected '*const u8' type, found '[5]u8'",
48414872 );
48424873
48434874 cases.add(
......@@ -4906,7 +4937,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
49064937 \\ var x: u2 = Small.Two;
49074938 \\}
49084939 ,
4909 ".tmp_source.zig:9:22: error: expected type 'u2', found 'Small'",
4940 ".tmp_source.zig:9:22: error: expected 'u2' type, found 'Small'",
49104941 );
49114942
49124943 cases.add(
......@@ -4923,7 +4954,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
49234954 \\ var x = @intToEnum(Small, y);
49244955 \\}
49254956 ,
4926 ".tmp_source.zig:10:31: error: expected type 'u2', found 'u3'",
4957 ".tmp_source.zig:10:31: error: expected 'u2' type, found 'u3'",
49274958 );
49284959
49294960 cases.add(
......@@ -5320,7 +5351,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
53205351 \\ asm volatile ("" : : [bar]"r"(3) : "");
53215352 \\}
53225353 ,
5323 ".tmp_source.zig:2:35: error: expected sized integer or sized float, found comptime_int",
5354 ".tmp_source.zig:2:35: error: expected sized integer or sized float type, found comptime_int",
53245355 );
53255356
53265357 cases.add(
......@@ -5329,6 +5360,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
53295360 \\ asm volatile ("" : : [bar]"r"(3.17) : "");
53305361 \\}
53315362 ,
5332 ".tmp_source.zig:2:35: error: expected sized integer or sized float, found comptime_float",
5363 ".tmp_source.zig:2:35: error: expected sized integer or sized float type, found comptime_float",
53335364 );
53345365}