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
signature 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 {
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 '*Derp' type, found '*Wat'#}
6027 {#code_begin|test_err|expected type '*Derp', found '*Wat'#}
60286028const Derp = @OpaqueType();
60296029const Wat = @OpaqueType();
60306030
src/ir.cpp+144-91
......@@ -9771,19 +9771,13 @@ 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, ZigTypeId wanted_type) {
9774static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) {
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
97849778 if (type_value->value.type->id != ZigTypeIdMetaType) {
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)));
9779 ir_add_error(ira, type_value,
9780 buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value.type->name)));
97879781 return ira->codegen->builtin_types.entry_invalid;
97889782 }
97899783
......@@ -9792,16 +9786,35 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value, ZigTy
97929786 return ira->codegen->builtin_types.entry_invalid;
97939787
97949788 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) {
9799 ir_add_error(ira, type_value,
9800 buf_sprintf( "expected %s type, found '%s'", expected_type_str, buf_ptr(&out_type->name)));
9796 if (type_value->value.type->id != ZigTypeIdMetaType) {
9797 ErrorMsg *msg = ir_add_error(ira, type_value,
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"));
98019801 return ira->codegen->builtin_types.entry_invalid;
98029802 }
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;
98059818}
98069819
98079820static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) {
......@@ -11001,7 +11014,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1100111014 }
1100211015
1100311016 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'",
1100511018 buf_ptr(&wanted_type->name),
1100611019 buf_ptr(&actual_type->name)));
1100711020 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
1222912242 size_t op2_array_end;
1223012243 if (op2_type->id == ZigTypeIdArray) {
1223112244 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'",
1223312246 buf_ptr(&child_type->name),
1223412247 buf_ptr(&op2->value.type->name)));
1223512248 return ira->codegen->invalid_instruction;
......@@ -12243,7 +12256,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1224312256 op2_val->data.x_ptr.data.base_array.is_cstr)
1224412257 {
1224512258 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'",
1224712260 buf_ptr(&child_type->name),
1224812261 buf_ptr(&op2->value.type->name)));
1224912262 return ira->codegen->invalid_instruction;
......@@ -12254,7 +12267,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1225412267 } else if (is_slice(op2_type)) {
1225512268 ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry;
1225612269 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'",
1225812271 buf_ptr(&child_type->name),
1225912272 buf_ptr(&op2->value.type->name)));
1226012273 return ira->codegen->invalid_instruction;
......@@ -12268,7 +12281,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i
1226812281 op2_array_end = bigint_as_unsigned(&len_val->data.x_bigint);
1226912282 } else {
1227012283 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)));
1227212285 return ira->codegen->invalid_instruction;
1227312286 }
1227412287
......@@ -12403,19 +12416,11 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *
1240312416}
1240412417
1240512418static IrInstruction *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstructionBinOp *instruction) {
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 }
12419 ZigType *op1_type = ir_resolve_error_set_type(ira, &instruction->base, instruction->op1->child);
12420 if (type_is_invalid(op1_type))
1241512421 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);
1241912424 if (type_is_invalid(op2_type))
1242012425 return ira->codegen->invalid_instruction;
1242112426
......@@ -12506,7 +12511,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruct
1250612511 IrInstruction *var_type = nullptr;
1250712512 if (decl_var_instruction->var_type != nullptr) {
1250812513 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);
1251012515 explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type);
1251112516 if (type_is_invalid(explicit_type)) {
1251212517 var->value->type = ira->codegen->builtin_types.entry_invalid;
......@@ -12835,14 +12840,21 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira,
1283512840{
1283612841 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);
1283912844 if (type_is_invalid(err_set_type))
1284012845 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);
1284312848 if (type_is_invalid(payload_type))
1284412849 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
1284612858 if ((err = type_resolve(ira->codegen, payload_type, ResolveStatusSizeKnown)))
1284712859 return ira->codegen->invalid_instruction;
1284812860 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
1290412916 ZigType *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type;
1290512917 if (alloc_fn_type->id != ZigTypeIdFn) {
1290612918 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)));
1290812920 return ira->codegen->invalid_instruction;
1290912921 }
1291012922
......@@ -13696,7 +13708,7 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC
1369613708
1369713709 if (is_comptime || instr_is_comptime(fn_ref)) {
1369813710 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);
1370013712 if (type_is_invalid(dest_type))
1370113713 return ira->codegen->invalid_instruction;
1370213714
......@@ -13821,7 +13833,7 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source
1382113833static IrInstruction *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instruction) {
1382213834 Error err;
1382313835 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);
1382513837 if (type_is_invalid(type_entry))
1382613838 return ira->codegen->invalid_instruction;
1382713839 if ((err = ensure_complete_type(ira->codegen, type_entry)))
......@@ -15304,10 +15316,16 @@ static IrInstruction *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira,
1530415316 IrInstructionPtrTypeChild *ptr_type_child_instruction)
1530515317{
1530615318 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);
1530815320 if (type_is_invalid(type_entry))
1530915321 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
1531115329 return ir_const_type(ira, &ptr_type_child_instruction->base, type_entry->data.pointer.child_type);
1531215330}
1531315331
......@@ -15460,7 +15478,7 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira,
1546015478 return ira->codegen->invalid_instruction;
1546115479 }
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);
1546415482 if (type_is_invalid(child_type))
1546515483 return ira->codegen->invalid_instruction;
1546615484
......@@ -15543,7 +15561,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs
1554315561 AsmOutput *asm_output = asm_expr->output_list.at(i);
1554415562 if (asm_output->return_type) {
1554515563 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]);
1554715565 if (type_is_invalid(return_type))
1554815566 return ira->codegen->invalid_instruction;
1554915567 }
......@@ -15558,7 +15576,7 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs
1555815576 (input_value->value.type->id == ZigTypeIdComptimeInt ||
1555915577 input_value->value.type->id == ZigTypeIdComptimeFloat)) {
1556015578 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)));
1556215580 return ira->codegen->invalid_instruction;
1556315581 }
1556415582
......@@ -15584,7 +15602,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira,
1558415602 return ira->codegen->invalid_instruction;
1558515603
1558615604 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);
1558815606 if (type_is_invalid(child_type))
1558915607 return ira->codegen->invalid_instruction;
1559015608 switch (child_type->id) {
......@@ -15633,7 +15651,7 @@ static IrInstruction *ir_analyze_instruction_promise_type(IrAnalyze *ira, IrInst
1563315651 if (instruction->payload_type == nullptr) {
1563415652 promise_type = ira->codegen->builtin_types.entry_promise;
1563515653 } 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);
1563715655 if (type_is_invalid(payload_type))
1563815656 return ira->codegen->invalid_instruction;
1563915657
......@@ -15648,7 +15666,7 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira,
1564815666{
1564915667 Error err;
1565015668 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
1565315671 if ((err = ensure_complete_type(ira->codegen, type_entry)))
1565415672 return ira->codegen->invalid_instruction;
......@@ -16483,7 +16501,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
1648316501
1648416502 size_t elem_count = instruction->item_count;
1648516503 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);
1648716505 if (type_is_invalid(container_type))
1648816506 return ira->codegen->invalid_instruction;
1648916507
......@@ -16599,7 +16617,7 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
1659916617
1660016618static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, IrInstructionContainerInitFields *instruction) {
1660116619 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);
1660316621 if (type_is_invalid(container_type))
1660416622 return ira->codegen->invalid_instruction;
1660516623
......@@ -16717,7 +16735,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
1671716735{
1671816736 Error err;
1671916737 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);
1672116739 if (type_is_invalid(container_type))
1672216740 return ira->codegen->invalid_instruction;
1672316741
......@@ -16730,6 +16748,12 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
1673016748 if (type_is_invalid(field_ptr->value.type))
1673116749 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
1673316757 if ((err = ensure_complete_type(ira->codegen, container_type)))
1673416758 return ira->codegen->invalid_instruction;
1673516759
......@@ -16743,7 +16767,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
1674316767
1674416768 if (field_ptr->value.type->id != ZigTypeIdPointer) {
1674516769 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)));
1674716771 return ira->codegen->invalid_instruction;
1674816772 }
1674916773
......@@ -16802,9 +16826,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira,
1680216826static TypeStructField *validate_byte_offset(IrAnalyze *ira,
1680316827 IrInstruction *type_value,
1680416828 IrInstruction *field_name_value,
16805 size_t *byte_offset)
16829 size_t *byte_offset)
1680616830{
16807 ZigType *container_type = ir_resolve_type(ira, type_value, ZigTypeIdStruct);
16831 ZigType *container_type = ir_resolve_type(ira, type_value);
1680816832 if (type_is_invalid(container_type))
1680916833 return nullptr;
1681016834
......@@ -16816,6 +16840,12 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira,
1681616840 if (!field_name)
1681716841 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
1681916849 TypeStructField *field = find_struct_type_field(container_type, field_name);
1682016850 if (field == nullptr) {
1682116851 ir_add_error(ira, field_name_value,
......@@ -17793,7 +17823,7 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira,
1779317823{
1779417824 Error err;
1779517825 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);
1779717827 if (type_is_invalid(type_entry))
1779817828 return ira->codegen->invalid_instruction;
1779917829
......@@ -17821,7 +17851,7 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira,
1782117851 IrInstructionTypeId *instruction)
1782217852{
1782317853 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);
1782517855 if (type_is_invalid(type_entry))
1782617856 return ira->codegen->invalid_instruction;
1782717857
......@@ -17856,7 +17886,7 @@ static IrInstruction *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ir
1785617886
1785717887static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) {
1785817888 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);
1786017890 if (type_is_invalid(type_entry))
1786117891 return ira->codegen->invalid_instruction;
1786217892
......@@ -18133,7 +18163,7 @@ static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstruction
1813318163
1813418164static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) {
1813518165 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);
1813718167 if (type_is_invalid(dest_type))
1813818168 return ira->codegen->invalid_instruction;
1813918169
......@@ -18186,7 +18216,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct
1818618216}
1818718217
1818818218static 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);
1819018220 if (type_is_invalid(dest_type))
1819118221 return ira->codegen->invalid_instruction;
1819218222
......@@ -18219,7 +18249,7 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct
1821918249}
1822018250
1822118251static 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);
1822318253 if (type_is_invalid(dest_type))
1822418254 return ira->codegen->invalid_instruction;
1822518255
......@@ -18259,10 +18289,16 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru
1825918289}
1826018290
1826118291static 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);
1826318293 if (type_is_invalid(dest_type))
1826418294 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
1826618302 IrInstruction *target = instruction->target->child;
1826718303 if (type_is_invalid(target->value.type))
1826818304 return ira->codegen->invalid_instruction;
......@@ -18291,7 +18327,7 @@ static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_ali
1829118327static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) {
1829218328 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);
1829518331 if (type_is_invalid(dest_child_type))
1829618332 return ira->codegen->invalid_instruction;
1829718333
......@@ -18388,7 +18424,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct
1838818424
1838918425 if (!is_slice(target->value.type)) {
1839018426 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)));
1839218428 return ira->codegen->invalid_instruction;
1839318429 }
1839418430
......@@ -18407,7 +18443,7 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct
1840718443}
1840818444
1840918445static 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);
1841118447 if (type_is_invalid(dest_type))
1841218448 return ira->codegen->invalid_instruction;
1841318449
......@@ -18425,7 +18461,7 @@ static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInst
1842518461}
1842618462
1842718463static 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);
1842918465 if (type_is_invalid(dest_type))
1843018466 return ira->codegen->invalid_instruction;
1843118467
......@@ -18481,7 +18517,7 @@ static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstr
1848118517 return ira->codegen->invalid_instruction;
1848218518
1848318519 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'",
1848518521 buf_ptr(&target->value.type->name)));
1848618522 return ira->codegen->invalid_instruction;
1848718523 }
......@@ -19062,7 +19098,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst
1906219098 IrInstruction *container = instruction->container->child;
1906319099 if (type_is_invalid(container->value.type))
1906419100 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
1906719103 if ((err = ensure_complete_type(ira->codegen, container_type)))
1906819104 return ira->codegen->invalid_instruction;
......@@ -19096,7 +19132,7 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst
1909619132static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) {
1909719133 Error err;
1909819134 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);
1910019136 if (type_is_invalid(container_type))
1910119137 return ira->codegen->invalid_instruction;
1910219138
......@@ -19139,7 +19175,7 @@ static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstr
1913919175static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) {
1914019176 Error err;
1914119177 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);
1914319179 if (type_is_invalid(container_type))
1914419180 return ira->codegen->invalid_instruction;
1914519181
......@@ -19232,7 +19268,7 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct
1923219268 IrInstruction *type_value = instruction->type_value->child;
1923319269 if (type_is_invalid(type_value->value.type))
1923419270 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
1923719273 if ((err = type_resolve(ira->codegen, type_entry, ResolveStatusAlignmentKnown)))
1923819274 return ira->codegen->invalid_instruction;
......@@ -19282,10 +19318,16 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr
1928219318 if (type_is_invalid(type_value->value.type))
1928319319 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);
1928619322 if (type_is_invalid(dest_type))
1928719323 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
1928919331 IrInstruction *op1 = instruction->op1->child;
1929019332 if (type_is_invalid(op1->value.type))
1929119333 return ira->codegen->invalid_instruction;
......@@ -19555,7 +19597,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
1955519597 IrInstruction *param_type_value = instruction->param_types[fn_type_id.next_param_index]->child;
1955619598 if (type_is_invalid(param_type_value->value.type))
1955719599 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);
1955919601 switch (type_requires_comptime(ira->codegen, param_type)) {
1956019602 case ReqCompTimeYes:
1956119603 if (!calling_convention_allows_zig_types(fn_type_id.cc)) {
......@@ -19589,7 +19631,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
1958919631 }
1959019632
1959119633 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);
1959319635 if (type_is_invalid(fn_type_id.return_type))
1959419636 return ira->codegen->invalid_instruction;
1959519637 if (fn_type_id.return_type->id == ZigTypeIdOpaque) {
......@@ -19605,7 +19647,7 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct
1960519647 return ira->codegen->invalid_instruction;
1960619648 }
1960719649 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);
1960919651 if (type_is_invalid(fn_type_id.async_allocator_type))
1961019652 return ira->codegen->invalid_instruction;
1961119653 }
......@@ -19913,7 +19955,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3
1991319955 result_type = get_slice_type(ira->codegen, result_ptr_type);
1991419956 } else {
1991519957 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)));
1991719959 return ira->codegen->invalid_instruction;
1991819960 }
1991919961
......@@ -19959,13 +20001,13 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_
1995920001 // validate src_type and dest_type.
1996020002
1996120003 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)));
1996320005 return ira->codegen->invalid_instruction;
1996420006 }
1996520007
1996620008 if (get_src_ptr_type(dest_type) == nullptr) {
1996720009 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)));
1996920011 return ira->codegen->invalid_instruction;
1997020012 }
1997120013
......@@ -20033,7 +20075,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_
2003320075
2003420076static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCast *instruction) {
2003520077 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);
2003720079 if (type_is_invalid(dest_type))
2003820080 return ira->codegen->invalid_instruction;
2003920081
......@@ -20229,7 +20271,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou
2022920271static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBitCast *instruction) {
2023020272 Error err;
2023120273 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);
2023320275 if (type_is_invalid(dest_type))
2023420276 return ira->codegen->invalid_instruction;
2023520277
......@@ -20326,13 +20368,13 @@ static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruct
2032620368static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) {
2032720369 Error err;
2032820370 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);
2033020372 if (type_is_invalid(dest_type))
2033120373 return ira->codegen->invalid_instruction;
2033220374
2033320375 // We explicitly check for the size, so we can use get_src_ptr_type
2033420376 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)));
2033620378 return ira->codegen->invalid_instruction;
2033720379 }
2033820380
......@@ -20435,7 +20477,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru
2043520477 // We check size explicitly so we can use get_src_ptr_type here.
2043620478 if (get_src_ptr_type(target->value.type) == nullptr) {
2043720479 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)));
2043920481 return ira->codegen->invalid_instruction;
2044020482 }
2044120483
......@@ -20466,7 +20508,7 @@ static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstru
2046620508
2046720509static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) {
2046820510 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);
2047020512 if (type_is_invalid(child_type))
2047120513 return ira->codegen->invalid_instruction;
2047220514
......@@ -20565,7 +20607,7 @@ static IrInstruction *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrI
2056520607
2056620608static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) {
2056720609 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);
2056920611 if (type_is_invalid(fn_type))
2057020612 return ira->codegen->invalid_instruction;
2057120613
......@@ -20574,6 +20616,11 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct
2057420616 if (!ir_resolve_usize(ira, arg_index_inst, &arg_index))
2057520617 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
2057720624 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
2057820625 if (arg_index >= fn_type_id->param_count) {
2057920626 ir_add_error(ira, arg_index_inst,
......@@ -20598,7 +20645,7 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct
2059820645static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) {
2059920646 Error err;
2060020647 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);
2060220649 if (type_is_invalid(enum_type))
2060320650 return ira->codegen->invalid_instruction;
2060420651
......@@ -20623,7 +20670,7 @@ static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstruct
2062320670 return ira->codegen->invalid_instruction;
2062420671 }
2062520672 } 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'",
2062720674 buf_ptr(&enum_type->name)));
2062820675 return ira->codegen->invalid_instruction;
2062920676 }
......@@ -20777,7 +20824,7 @@ static IrInstruction *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInst
2077720824 if (coro_handle->value.type->id != ZigTypeIdPromise ||
2077820825 coro_handle->value.type->data.promise.result_type == nullptr)
2077920826 {
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'",
2078120828 buf_ptr(&coro_handle->value.type->name)));
2078220829 return ira->codegen->invalid_instruction;
2078320830 }
......@@ -20808,7 +20855,7 @@ static IrInstruction *ir_analyze_instruction_coro_alloc_helper(IrAnalyze *ira, I
2080820855}
2080920856
2081020857static 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);
2081220859 if (type_is_invalid(operand_type))
2081320860 return ira->codegen->builtin_types.entry_invalid;
2081420861
......@@ -20938,12 +20985,12 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr
2093820985}
2093920986
2094020987static 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);
2094220989 if (type_is_invalid(promise_type))
2094320990 return ira->codegen->invalid_instruction;
2094420991
2094520992 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'",
2094720994 buf_ptr(&promise_type->name)));
2094820995 return ira->codegen->invalid_instruction;
2094920996 }
......@@ -20952,7 +20999,7 @@ static IrInstruction *ir_analyze_instruction_promise_result_type(IrAnalyze *ira,
2095220999}
2095321000
2095421001static 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);
2095621003 if (type_is_invalid(promise_result_type))
2095721004 return ira->codegen->invalid_instruction;
2095821005
......@@ -21015,7 +21062,7 @@ static IrInstruction *ir_analyze_instruction_mark_err_ret_trace_ptr(IrAnalyze *i
2101521062}
2101621063
2101721064static 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);
2101921066 if (type_is_invalid(float_type))
2102021067 return ira->codegen->invalid_instruction;
2102121068
......@@ -21082,7 +21129,7 @@ static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionS
2108221129}
2108321130
2108421131static 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);
2108621133 if (type_is_invalid(int_type))
2108721134 return ira->codegen->invalid_instruction;
2108821135
......@@ -21138,7 +21185,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction
2113821185}
2113921186
2114021187static 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);
2114221189 if (type_is_invalid(int_type))
2114321190 return ira->codegen->invalid_instruction;
2114421191
......@@ -21209,7 +21256,7 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr
2120921256
2121021257 if (target->value.type->id != ZigTypeIdEnum) {
2121121258 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)));
2121321260 return ira->codegen->invalid_instruction;
2121421261 }
2121521262
......@@ -21224,10 +21271,16 @@ static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstr
2122421271static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) {
2122521272 Error err;
2122621273 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);
2122821275 if (type_is_invalid(dest_type))
2122921276 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
2123121284 if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown)))
2123221285 return ira->codegen->invalid_instruction;
2123321286
src/parser.cpp+6-29
......@@ -122,37 +122,19 @@ static AstNode *ast_parse_container_decl_type(ParseContext *pc);
122122static AstNode *ast_parse_byte_align(ParseContext *pc);
123123
124124ATTRIBUTE_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)
140125ATTRIBUTE_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, ...) {
142127 va_list ap;
143128 va_start(ap, format);
144129 Buf *msg = buf_vprintf(format, ap);
145130 va_end(ap);
146131
132
147133 ErrorMsg *err = err_msg_create_with_line(pc->owner->path, token->start_line, token->start_column,
148134 pc->owner->source_code, pc->owner->line_offsets, msg);
149135 err->line_start = token->start_line;
150136 err->column_start = token->start_column;
151137
152 if (note) {
153 err->notes.append(note);
154 }
155
156138 print_err_msg(err, pc->err_color);
157139 exit(EXIT_FAILURE);
158140}
......@@ -182,7 +164,7 @@ static Buf ast_token_str(Buf *input, Token *token) {
182164ATTRIBUTE_NORETURN
183165static void ast_invalid_token_error(ParseContext *pc, Token *token) {
184166 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));
186168}
187169
188170static AstNode *ast_create_node_no_line_info(ParseContext *pc, NodeType type) {
......@@ -232,13 +214,8 @@ static Token *eat_token_if(ParseContext *pc, TokenId id) {
232214
233215static Token *expect_token(ParseContext *pc, TokenId id) {
234216 Token *res = eat_token(pc);
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 }
217 if (res->id != id)
218 ast_error(pc, res, "expected token '%s', found '%s'", token_name(id), token_name(res->id));
242219
243220 return res;
244221}
......@@ -860,7 +837,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
860837 if (param_decl->data.param_decl.is_var_args)
861838 res->data.fn_proto.is_var_args = true;
862839 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.");
864841 }
865842 return res;
866843}
src/tokenizer.cpp+3-12
......@@ -199,7 +199,6 @@ enum TokenizeState {
199199 TokenizeStateSawDash,
200200 TokenizeStateSawMinusPercent,
201201 TokenizeStateSawAmpersand,
202 TokenizeStateSawAmpersandAmpersand,
203202 TokenizeStateSawCaret,
204203 TokenizeStateSawBar,
205204 TokenizeStateSawBarBar,
......@@ -887,15 +886,14 @@ void tokenize(Buf *buf, Tokenization *out) {
887886 break;
888887 case TokenizeStateSawAmpersand:
889888 switch (c) {
889 case '&':
890 tokenize_error(&t, "`&&` is invalid. Note that `and` is boolean AND.");
891 break;
890892 case '=':
891893 set_token_id(&t, t.cur_tok, TokenIdBitAndEq);
892894 end_token(&t);
893895 t.state = TokenizeStateStart;
894896 break;
895 case '&':
896 set_token_id(&t, t.cur_tok, TokenIdAmpersandAmpersand);
897 t.state = TokenizeStateSawAmpersandAmpersand;
898 break;
899897 default:
900898 t.pos -= 1;
901899 end_token(&t);
......@@ -903,11 +901,6 @@ void tokenize(Buf *buf, Tokenization *out) {
903901 continue;
904902 }
905903 break;
906 case TokenizeStateSawAmpersandAmpersand:
907 t.pos -= 1;
908 end_token(&t);
909 t.state = TokenizeStateStart;
910 continue;
911904 case TokenizeStateSawCaret:
912905 switch (c) {
913906 case '=':
......@@ -1478,7 +1471,6 @@ void tokenize(Buf *buf, Tokenization *out) {
14781471 case TokenizeStateSawPlus:
14791472 case TokenizeStateSawDash:
14801473 case TokenizeStateSawAmpersand:
1481 case TokenizeStateSawAmpersandAmpersand:
14821474 case TokenizeStateSawCaret:
14831475 case TokenizeStateSawBar:
14841476 case TokenizeStateSawEq:
......@@ -1526,7 +1518,6 @@ void tokenize(Buf *buf, Tokenization *out) {
15261518const char * token_name(TokenId id) {
15271519 switch (id) {
15281520 case TokenIdAmpersand: return "&";
1529 case TokenIdAmpersandAmpersand: return "&&";
15301521 case TokenIdArrow: return "->";
15311522 case TokenIdAtSign: return "@";
15321523 case TokenIdBang: return "!";
src/tokenizer.hpp-1
......@@ -14,7 +14,6 @@
1414
1515enum TokenId {
1616 TokenIdAmpersand,
17 TokenIdAmpersandAmpersand,
1817 TokenIdArrow,
1918 TokenIdAtSign,
2019 TokenIdBang,
test/compile_errors.zig+74-78
......@@ -2,33 +2,28 @@ const tests = @import("tests.zig");
22
33pub fn addCases(cases: *tests.CompileErrorContext) void {
44 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;
5 "attempted `&&`",
6 \\export fn entry(a: bool, b: bool) i32 {
7 \\ if (a && b) {
8 \\ return 1234;
9 \\ }
10 \\ return 5678;
1811 \\}
1912 ,
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`?",
13 ".tmp_source.zig:2:11: error: `&&` is invalid. Note that `and` is boolean AND.",
2214 );
2315
2416 cases.add(
25 "Use of || in place of `or` (using booleans)",
26 \\export fn entry() void {
27 \\ if (true || false) return;
17 "attempted `||` on boolean values",
18 \\export fn entry(a: bool, b: bool) i32 {
19 \\ if (a || b) {
20 \\ return 1234;
21 \\ }
22 \\ return 5678;
2823 \\}
2924 ,
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`?",
25 ".tmp_source.zig:2:9: error: expected error set type, found 'bool'",
26 ".tmp_source.zig:2:11: note: `||` merges error sets; `or` performs boolean OR",
3227 );
3328
3429 cases.add(
......@@ -98,7 +93,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
9893 \\ do_the_thing(bar);
9994 \\}
10095 ,
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",
10297 ".tmp_source.zig:4:18: note: parameter 0: 'bool' cannot cast into 'i32'",
10398 );
10499
......@@ -134,7 +129,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
134129 ,
135130 ".tmp_source.zig:3:31: error: integer value 300 cannot be implicitly casted to type 'u8'",
136131 ".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'",
138133 );
139134
140135 cases.add(
......@@ -154,7 +149,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
154149 \\
155150 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
156151 ,
157 ".tmp_source.zig:2:14: error: expected 'f32' type, found 'f64'",
152 ".tmp_source.zig:2:14: error: expected type 'f32', found 'f64'",
158153 );
159154
160155 cases.add(
......@@ -202,7 +197,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
202197 \\ var ptr2: *c_void = &b;
203198 \\}
204199 ,
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'",
206201 );
207202
208203 cases.add(
......@@ -252,7 +247,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
252247 \\ const sliceA: []u8 = &buffer;
253248 \\}
254249 ,
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'",
256251 );
257252
258253 cases.add(
......@@ -297,9 +292,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
297292 \\ const Errors = error{} || u16;
298293 \\}
299294 ,
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'",
295 ".tmp_source.zig:2:20: error: expected error set type, found type 'u8'",
296 ".tmp_source.zig:2:23: note: `||` merges error sets; `or` performs boolean OR",
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",
303299 );
304300
305301 cases.add(
......@@ -794,7 +790,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
794790 \\
795791 \\fn bar(x: *b.Foo) void {}
796792 ,
797 ".tmp_source.zig:6:10: error: expected '*Foo' type, found '*Foo'",
793 ".tmp_source.zig:6:10: error: expected type '*Foo', found '*Foo'",
798794 ".tmp_source.zig:6:10: note: pointer type child 'Foo' cannot cast into pointer type child 'Foo'",
799795 "a.zig:1:17: note: Foo declared here",
800796 "b.zig:1:17: note: Foo declared here",
......@@ -864,7 +860,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
864860 \\ var y = p.*;
865861 \\}
866862 ,
867 ".tmp_source.zig:4:23: error: expected '*?*i32' type, found '**i32'",
863 ".tmp_source.zig:4:23: error: expected type '*?*i32', found '**i32'",
868864 );
869865
870866 cases.add(
......@@ -873,7 +869,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
873869 \\ const x: [*]const bool = true;
874870 \\}
875871 ,
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'",
877873 );
878874
879875 cases.add(
......@@ -918,7 +914,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
918914 \\ var rule_set = try Foo.init();
919915 \\}
920916 ,
921 ".tmp_source.zig:2:13: error: expected 'i32' type, found 'type'",
917 ".tmp_source.zig:2:13: error: expected type 'i32', found 'type'",
922918 );
923919
924920 cases.add(
......@@ -952,7 +948,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
952948 \\ return null;
953949 \\}
954950 ,
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'",
956952 ".tmp_source.zig:5:34: note: optional type child 'OtherError!i32' cannot cast into optional type child 'NextError!i32'",
957953 ".tmp_source.zig:5:34: note: error set 'OtherError' cannot cast into error set 'NextError'",
958954 ".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 {
10221018 \\ @panic(e);
10231019 \\}
10241020 ,
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}'",
10261022 );
10271023
10281024 cases.add(
......@@ -1050,7 +1046,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
10501046 \\ return error.ShouldBeCompileError;
10511047 \\}
10521048 ,
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}'",
10541050 );
10551051
10561052 cases.add(
......@@ -1093,7 +1089,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
10931089 \\ a(c);
10941090 \\}
10951091 ,
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'",
10971093 );
10981094
10991095 cases.add(
......@@ -1175,7 +1171,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
11751171 \\ E.One => {},
11761172 \\ }
11771173 \\}
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
11801176 cases.add(
11811177 "range operator in switch used on error set",
......@@ -1221,7 +1217,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
12211217 \\ const z = i32!i32;
12221218 \\}
12231219 ,
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'",
12251221 );
12261222
12271223 cases.add(
......@@ -1271,7 +1267,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
12711267 \\ return error.B;
12721268 \\}
12731269 ,
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'",
12751271 ".tmp_source.zig:3:35: note: error set 'anyerror' cannot cast into error set 'SmallErrorSet'",
12761272 ".tmp_source.zig:3:35: note: cannot cast global error set into smaller set",
12771273 );
......@@ -1286,7 +1282,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
12861282 \\ return error.B;
12871283 \\}
12881284 ,
1289 ".tmp_source.zig:3:31: error: expected 'SmallErrorSet' type, found 'anyerror'",
1285 ".tmp_source.zig:3:31: error: expected type 'SmallErrorSet', found 'anyerror'",
12901286 ".tmp_source.zig:3:31: note: cannot cast global error set into smaller set",
12911287 );
12921288
......@@ -1313,7 +1309,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
13131309 \\ var x: Set2 = set1;
13141310 \\}
13151311 ,
1316 ".tmp_source.zig:7:19: error: expected 'Set2' type, found 'Set1'",
1312 ".tmp_source.zig:7:19: error: expected type 'Set2', found 'Set1'",
13171313 ".tmp_source.zig:1:23: note: 'error.B' not a member of destination error set",
13181314 );
13191315
......@@ -1853,7 +1849,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
18531849 \\fn a() noreturn {return;}
18541850 \\export fn entry() void { a(); }
18551851 ,
1856 ".tmp_source.zig:1:18: error: expected 'noreturn' type, found 'void'",
1852 ".tmp_source.zig:1:18: error: expected type 'noreturn', found 'void'",
18571853 );
18581854
18591855 cases.add(
......@@ -1861,7 +1857,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
18611857 \\fn a() i32 {}
18621858 \\export fn entry() void { _ = a(); }
18631859 ,
1864 ".tmp_source.zig:1:12: error: expected 'i32' type, found 'void'",
1860 ".tmp_source.zig:1:12: error: expected type 'i32', found 'void'",
18651861 );
18661862
18671863 cases.add(
......@@ -1967,7 +1963,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
19671963 \\ return a;
19681964 \\}
19691965 ,
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'",
19711967 );
19721968
19731969 cases.add(
......@@ -1976,7 +1972,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
19761972 \\ if (0) {}
19771973 \\}
19781974 ,
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'",
19801976 );
19811977
19821978 cases.add(
......@@ -2071,8 +2067,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
20712067 \\ array[bad] = array[bad];
20722068 \\}
20732069 ,
2074 ".tmp_source.zig:4:11: error: expected 'usize' type, found 'bool'",
2075 ".tmp_source.zig:4:24: error: expected 'usize' type, found 'bool'",
2070 ".tmp_source.zig:4:11: error: expected type 'usize', found 'bool'",
2071 ".tmp_source.zig:4:24: error: expected type 'usize', found 'bool'",
20762072 );
20772073
20782074 cases.add(
......@@ -2486,7 +2482,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
24862482 \\fn foo() *const i32 { return y; }
24872483 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
24882484 ,
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'",
24902486 );
24912487
24922488 cases.add(
......@@ -2564,7 +2560,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
25642560 \\fn c() i32 {return 2;}
25652561 \\export fn entry() usize { return @sizeOf(@typeOf(fns)); }
25662562 ,
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'",
25682564 );
25692565
25702566 cases.add(
......@@ -2576,7 +2572,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
25762572 \\
25772573 \\export fn entry() usize { return @sizeOf(@typeOf(fns)); }
25782574 ,
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'",
25802576 );
25812577
25822578 cases.add(
......@@ -2680,7 +2676,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
26802676 \\
26812677 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
26822678 ,
2683 ".tmp_source.zig:1:16: error: expected '*u8' type, found '(null)'",
2679 ".tmp_source.zig:1:16: error: expected type '*u8', found '(null)'",
26842680 );
26852681
26862682 cases.add(
......@@ -3320,7 +3316,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
33203316 \\}
33213317 \\fn something() anyerror!void { }
33223318 ,
3323 ".tmp_source.zig:2:5: error: expected 'void' type, found 'anyerror'",
3319 ".tmp_source.zig:2:5: error: expected type 'void', found 'anyerror'",
33243320 ".tmp_source.zig:1:15: note: return type declared here",
33253321 );
33263322
......@@ -3499,7 +3495,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
34993495 \\ derp.init();
35003496 \\}
35013497 ,
3502 ".tmp_source.zig:14:5: error: expected 'i32' type, found 'Foo'",
3498 ".tmp_source.zig:14:5: error: expected type 'i32', found 'Foo'",
35033499 );
35043500
35053501 cases.add(
......@@ -3529,7 +3525,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
35293525 \\ x.init();
35303526 \\}
35313527 ,
3532 ".tmp_source.zig:23:5: error: expected '*Allocator' type, found '*List'",
3528 ".tmp_source.zig:23:5: error: expected type '*Allocator', found '*List'",
35333529 );
35343530
35353531 cases.add(
......@@ -3701,7 +3697,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
37013697 \\
37023698 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
37033699 ,
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'",
37053701 );
37063702
37073703 cases.add(
......@@ -3830,7 +3826,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38303826 \\
38313827 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
38323828 ,
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'",
38343830 );
38353831
38363832 cases.addCase(x: {
......@@ -3862,7 +3858,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38623858 \\ foo(global_array);
38633859 \\}
38643860 ,
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'",
38663862 );
38673863
38683864 cases.add(
......@@ -3871,7 +3867,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38713867 \\ return @ptrCast(usize, a);
38723868 \\}
38733869 ,
3874 ".tmp_source.zig:2:21: error: expected Pointer type, found 'usize'",
3870 ".tmp_source.zig:2:21: error: expected pointer, found 'usize'",
38753871 );
38763872
38773873 cases.add(
......@@ -3918,7 +3914,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
39183914 \\ return @fieldParentPtr(Foo, "a", a);
39193915 \\}
39203916 ,
3921 ".tmp_source.zig:3:28: error: expected Struct type, found 'i32'",
3917 ".tmp_source.zig:3:28: error: expected struct type, found 'i32'",
39223918 );
39233919
39243920 cases.add(
......@@ -3942,7 +3938,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
39423938 \\ return @fieldParentPtr(Foo, "a", a);
39433939 \\}
39443940 ,
3945 ".tmp_source.zig:5:38: error: expected Pointer type, found 'i32'",
3941 ".tmp_source.zig:5:38: error: expected pointer, found 'i32'",
39463942 );
39473943
39483944 cases.add(
......@@ -3983,7 +3979,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
39833979 \\ return @byteOffsetOf(Foo, "a",);
39843980 \\}
39853981 ,
3986 ".tmp_source.zig:3:26: error: expected Struct type, found 'i32'",
3982 ".tmp_source.zig:3:26: error: expected struct type, found 'i32'",
39873983 );
39883984
39893985 cases.add(
......@@ -4097,7 +4093,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
40974093 \\}
40984094 \\fn bar() ?i32 { return 1; }
40994095 ,
4100 ".tmp_source.zig:2:15: error: expected 'bool' type, found '?i32'",
4096 ".tmp_source.zig:2:15: error: expected type 'bool', found '?i32'",
41014097 );
41024098
41034099 cases.add(
......@@ -4107,7 +4103,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
41074103 \\}
41084104 \\fn bar() anyerror!i32 { return 1; }
41094105 ,
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'",
41114107 );
41124108
41134109 cases.add(
......@@ -4368,7 +4364,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
43684364 \\ return @ptrToInt(x);
43694365 \\}
43704366 ,
4371 ".tmp_source.zig:2:22: error: expected Pointer type, found 'i32'",
4367 ".tmp_source.zig:2:22: error: expected pointer, found 'i32'",
43724368 );
43734369
43744370 cases.add(
......@@ -4404,7 +4400,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
44044400 \\ return x << y;
44054401 \\}
44064402 ,
4407 ".tmp_source.zig:2:17: error: expected 'u3' type, found 'u8'",
4403 ".tmp_source.zig:2:17: error: expected type 'u3', found 'u8'",
44084404 );
44094405
44104406 cases.add(
......@@ -4433,7 +4429,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
44334429 \\ x.* += 1;
44344430 \\}
44354431 ,
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'",
44374433 );
44384434
44394435 cases.add(
......@@ -4477,7 +4473,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
44774473 \\ @alignCast(4, u32(3));
44784474 \\}
44794475 ,
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'",
44814477 );
44824478
44834479 cases.add(
......@@ -4490,7 +4486,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
44904486 \\}
44914487 \\fn alignedSmall() align(4) i32 { return 1234; }
44924488 ,
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'",
44944490 );
44954491
44964492 cases.add(
......@@ -4502,7 +4498,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
45024498 \\ return x == 5678;
45034499 \\}
45044500 ,
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'",
45064502 );
45074503
45084504 cases.add(
......@@ -4537,7 +4533,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
45374533 \\ bar(@ptrCast(*c_void, &x));
45384534 \\}
45394535 ,
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'",
45414537 );
45424538
45434539 cases.add(
......@@ -4583,7 +4579,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
45834579 \\ while (!@cmpxchgWeak(i32, &x, 1234, 5678, u32(1234), u32(1234))) {}
45844580 \\}
45854581 ,
4586 ".tmp_source.zig:3:50: error: expected 'AtomicOrder' type, found 'u32'",
4582 ".tmp_source.zig:3:50: error: expected type 'AtomicOrder', found 'u32'",
45874583 );
45884584
45894585 cases.add(
......@@ -4593,7 +4589,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
45934589 \\ @export("entry", entry, u32(1234));
45944590 \\}
45954591 ,
4596 ".tmp_source.zig:3:32: error: expected 'GlobalLinkage' type, found 'u32'",
4592 ".tmp_source.zig:3:32: error: expected type 'GlobalLinkage', found 'u32'",
45974593 );
45984594
45994595 cases.add(
......@@ -4770,7 +4766,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
47704766 \\ _ = @ArgType(i32, 3);
47714767 \\}
47724768 ,
4773 ".tmp_source.zig:2:18: error: expected Fn type, found 'i32'",
4769 ".tmp_source.zig:2:18: error: expected function, found 'i32'",
47744770 );
47754771
47764772 cases.add(
......@@ -4868,7 +4864,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
48684864 \\}
48694865 \\pub extern fn foo(format: *const u8, ...) void;
48704866 ,
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'",
48724868 );
48734869
48744870 cases.add(
......@@ -4937,7 +4933,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
49374933 \\ var x: u2 = Small.Two;
49384934 \\}
49394935 ,
4940 ".tmp_source.zig:9:22: error: expected 'u2' type, found 'Small'",
4936 ".tmp_source.zig:9:22: error: expected type 'u2', found 'Small'",
49414937 );
49424938
49434939 cases.add(
......@@ -4954,7 +4950,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
49544950 \\ var x = @intToEnum(Small, y);
49554951 \\}
49564952 ,
4957 ".tmp_source.zig:10:31: error: expected 'u2' type, found 'u3'",
4953 ".tmp_source.zig:10:31: error: expected type 'u2', found 'u3'",
49584954 );
49594955
49604956 cases.add(
......@@ -5351,7 +5347,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
53515347 \\ asm volatile ("" : : [bar]"r"(3) : "");
53525348 \\}
53535349 ,
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",
53555351 );
53565352
53575353 cases.add(
......@@ -5360,6 +5356,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
53605356 \\ asm volatile ("" : : [bar]"r"(3.17) : "");
53615357 \\}
53625358 ,
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",
53645360 );
53655361}