| author | |
| committer | |
| log | 27cb23cbc5fe35d0eae8494006ba93111bd2bde6 |
| tree | d561c9284e24815a06f43a4eaad62cf24f21cbf5 |
| parent | d605af511a9af5d987a9e2276c2ed9a1b4e951c7 |
| signature |
3 files changed, 14 insertions(+), 12 deletions(-)
src-self-hosted/zir_sema.zig+3-3| ... | @@ -393,7 +393,7 @@ fn analyzeInstParamType(mod: *Module, scope: *Scope, inst: *zir.Inst.ParamType) | ... | @@ -393,7 +393,7 @@ fn analyzeInstParamType(mod: *Module, scope: *Scope, inst: *zir.Inst.ParamType) |
| 393 | // TODO support C-style var args | 393 | // TODO support C-style var args |
| 394 | const param_count = fn_ty.fnParamLen(); | 394 | const param_count = fn_ty.fnParamLen(); |
| 395 | if (arg_index >= param_count) { | 395 | if (arg_index >= param_count) { |
| 396 | return mod.fail(scope, inst.base.src, "arg index {} out of bounds; '{}' has {} arguments", .{ | 396 | return mod.fail(scope, inst.base.src, "arg index {} out of bounds; '{}' has {} argument(s)", .{ |
| 397 | arg_index, | 397 | arg_index, |
| 398 | fn_ty, | 398 | fn_ty, |
| 399 | param_count, | 399 | param_count, |
| ... | @@ -600,7 +600,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError | ... | @@ -600,7 +600,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError |
| 600 | return mod.fail( | 600 | return mod.fail( |
| 601 | scope, | 601 | scope, |
| 602 | inst.positionals.func.src, | 602 | inst.positionals.func.src, |
| 603 | "expected at least {} arguments, found {}", | 603 | "expected at least {} argument(s), found {}", |
| 604 | .{ fn_params_len, call_params_len }, | 604 | .{ fn_params_len, call_params_len }, |
| 605 | ); | 605 | ); |
| 606 | } | 606 | } |
| ... | @@ -610,7 +610,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError | ... | @@ -610,7 +610,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError |
| 610 | return mod.fail( | 610 | return mod.fail( |
| 611 | scope, | 611 | scope, |
| 612 | inst.positionals.func.src, | 612 | inst.positionals.func.src, |
| 613 | "expected {} arguments, found {}", | 613 | "expected {} argument(s), found {}", |
| 614 | .{ fn_params_len, call_params_len }, | 614 | .{ fn_params_len, call_params_len }, |
| 615 | ); | 615 | ); |
| 616 | } | 616 | } |
src/ir.cpp+7-5| ... | @@ -6349,9 +6349,9 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod | ... | @@ -6349,9 +6349,9 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod |
| 6349 | BuiltinFnEntry *builtin_fn = entry->value; | 6349 | BuiltinFnEntry *builtin_fn = entry->value; |
| 6350 | size_t actual_param_count = node->data.fn_call_expr.params.length; | 6350 | size_t actual_param_count = node->data.fn_call_expr.params.length; |
| 6351 | 6351 | ||
| 6352 | if (builtin_fn->param_count != SIZE_MAX && builtin_fn->param_count != actual_param_count) { | 6352 | if (builtin_fn->param_count != SIZE_MAX && builtin_fn->param_count != actual_param_count) { |
| 6353 | add_node_error(irb->codegen, node, | 6353 | add_node_error(irb->codegen, node, |
| 6354 | buf_sprintf("expected %" ZIG_PRI_usize " arguments, found %" ZIG_PRI_usize, | 6354 | buf_sprintf("expected %" ZIG_PRI_usize " argument(s), found %" ZIG_PRI_usize, |
| 6355 | builtin_fn->param_count, actual_param_count)); | 6355 | builtin_fn->param_count, actual_param_count)); |
| 6356 | return irb->codegen->invalid_inst_src; | 6356 | return irb->codegen->invalid_inst_src; |
| 6357 | } | 6357 | } |
| ... | @@ -20186,7 +20186,8 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -20186,7 +20186,8 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 20186 | if (fn_type_id->is_var_args) { | 20186 | if (fn_type_id->is_var_args) { |
| 20187 | if (call_param_count < src_param_count) { | 20187 | if (call_param_count < src_param_count) { |
| 20188 | ErrorMsg *msg = ir_add_error_node(ira, source_node, | 20188 | ErrorMsg *msg = ir_add_error_node(ira, source_node, |
| 20189 | buf_sprintf("expected at least %" ZIG_PRI_usize " arguments, found %" ZIG_PRI_usize "", src_param_count, call_param_count)); | 20189 | buf_sprintf("expected at least %" ZIG_PRI_usize " argument(s), found %" ZIG_PRI_usize "", |
| 20190 | src_param_count, call_param_count)); | ||
| 20190 | if (fn_proto_node) { | 20191 | if (fn_proto_node) { |
| 20191 | add_error_note(ira->codegen, msg, fn_proto_node, | 20192 | add_error_note(ira->codegen, msg, fn_proto_node, |
| 20192 | buf_sprintf("declared here")); | 20193 | buf_sprintf("declared here")); |
| ... | @@ -20195,7 +20196,8 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -20195,7 +20196,8 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 20195 | } | 20196 | } |
| 20196 | } else if (src_param_count != call_param_count) { | 20197 | } else if (src_param_count != call_param_count) { |
| 20197 | ErrorMsg *msg = ir_add_error_node(ira, source_node, | 20198 | ErrorMsg *msg = ir_add_error_node(ira, source_node, |
| 20198 | buf_sprintf("expected %" ZIG_PRI_usize " arguments, found %" ZIG_PRI_usize "", src_param_count, call_param_count)); | 20199 | buf_sprintf("expected %" ZIG_PRI_usize " argument(s), found %" ZIG_PRI_usize "", |
| 20200 | src_param_count, call_param_count)); | ||
| 20199 | if (fn_proto_node) { | 20201 | if (fn_proto_node) { |
| 20200 | add_error_note(ira->codegen, msg, fn_proto_node, | 20202 | add_error_note(ira->codegen, msg, fn_proto_node, |
| 20201 | buf_sprintf("declared here")); | 20203 | buf_sprintf("declared here")); |
| ... | @@ -30127,7 +30129,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy | ... | @@ -30127,7 +30129,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy |
| 30127 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_anytype); | 30129 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_anytype); |
| 30128 | } | 30130 | } |
| 30129 | ir_add_error(ira, &arg_index_inst->base, | 30131 | ir_add_error(ira, &arg_index_inst->base, |
| 30130 | buf_sprintf("arg index %" ZIG_PRI_u64 " out of bounds; '%s' has %" ZIG_PRI_usize " arguments", | 30132 | buf_sprintf("arg index %" ZIG_PRI_u64 " out of bounds; '%s' has %" ZIG_PRI_usize " argument(s)", |
| 30131 | arg_index, buf_ptr(&fn_type->name), fn_type_id->param_count)); | 30133 | arg_index, buf_ptr(&fn_type->name), fn_type_id->param_count)); |
| 30132 | return ira->codegen->invalid_inst_gen; | 30134 | return ira->codegen->invalid_inst_gen; |
| 30133 | } | 30135 | } |
test/compile_errors.zig+4-4| ... | @@ -705,7 +705,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -705,7 +705,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 705 | \\ for (arr) |bits| _ = @popCount(bits); | 705 | \\ for (arr) |bits| _ = @popCount(bits); |
| 706 | \\} | 706 | \\} |
| 707 | , &[_][]const u8{ | 707 | , &[_][]const u8{ |
| 708 | "tmp.zig:3:26: error: expected 2 arguments, found 1", | 708 | "tmp.zig:3:26: error: expected 2 argument(s), found 1", |
| 709 | }); | 709 | }); |
| 710 | 710 | ||
| 711 | cases.addTest("@call rejects non comptime-known fn - always_inline", | 711 | cases.addTest("@call rejects non comptime-known fn - always_inline", |
| ... | @@ -4103,7 +4103,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -4103,7 +4103,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4103 | \\} | 4103 | \\} |
| 4104 | \\fn b(a: i32, b: i32, c: i32) void { } | 4104 | \\fn b(a: i32, b: i32, c: i32) void { } |
| 4105 | , &[_][]const u8{ | 4105 | , &[_][]const u8{ |
| 4106 | "tmp.zig:2:6: error: expected 3 arguments, found 1", | 4106 | "tmp.zig:2:6: error: expected 3 argument(s), found 1", |
| 4107 | }); | 4107 | }); |
| 4108 | 4108 | ||
| 4109 | cases.add("invalid type", | 4109 | cases.add("invalid type", |
| ... | @@ -4716,7 +4716,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -4716,7 +4716,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4716 | \\ | 4716 | \\ |
| 4717 | \\export fn entry() usize { return @sizeOf(@TypeOf(f)); } | 4717 | \\export fn entry() usize { return @sizeOf(@TypeOf(f)); } |
| 4718 | , &[_][]const u8{ | 4718 | , &[_][]const u8{ |
| 4719 | "tmp.zig:20:34: error: expected 1 arguments, found 0", | 4719 | "tmp.zig:20:34: error: expected 1 argument(s), found 0", |
| 4720 | }); | 4720 | }); |
| 4721 | 4721 | ||
| 4722 | cases.add("missing function name", | 4722 | cases.add("missing function name", |
| ... | @@ -5498,7 +5498,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -5498,7 +5498,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5498 | \\} | 5498 | \\} |
| 5499 | \\export fn entry() usize { return @sizeOf(@TypeOf(f)); } | 5499 | \\export fn entry() usize { return @sizeOf(@TypeOf(f)); } |
| 5500 | , &[_][]const u8{ | 5500 | , &[_][]const u8{ |
| 5501 | "tmp.zig:6:15: error: expected 2 arguments, found 3", | 5501 | "tmp.zig:6:15: error: expected 2 argument(s), found 3", |
| 5502 | }); | 5502 | }); |
| 5503 | 5503 | ||
| 5504 | cases.add("assign through constant pointer", | 5504 | cases.add("assign through constant pointer", |