| author | |
| committer | |
| log | d6e3988fe846864a33adf9f5f04d800718b31392 |
| tree | e6678d0b0cc5c51f75112e19191de6d56dbe1914 |
| parent | 7862ab9f410d20d0cfe799bf025f8cf57dd6f15a |
14 files changed, 84 insertions(+), 76 deletions(-)
src/Sema.zig+12-6| ... | @@ -5496,7 +5496,7 @@ fn analyzeCall( | ... | @@ -5496,7 +5496,7 @@ fn analyzeCall( |
| 5496 | // TODO add error note: declared here | 5496 | // TODO add error note: declared here |
| 5497 | return sema.fail( | 5497 | return sema.fail( |
| 5498 | block, | 5498 | block, |
| 5499 | func_src, | 5499 | call_src, |
| 5500 | "expected {d} argument(s), found {d}", | 5500 | "expected {d} argument(s), found {d}", |
| 5501 | .{ fn_params_len, uncasted_args.len }, | 5501 | .{ fn_params_len, uncasted_args.len }, |
| 5502 | ); | 5502 | ); |
| ... | @@ -21275,7 +21275,7 @@ fn coerceExtra( | ... | @@ -21275,7 +21275,7 @@ fn coerceExtra( |
| 21275 | else => {}, | 21275 | else => {}, |
| 21276 | }, | 21276 | }, |
| 21277 | .ErrorUnion => switch (inst_ty.zigTypeTag()) { | 21277 | .ErrorUnion => switch (inst_ty.zigTypeTag()) { |
| 21278 | .ErrorUnion => { | 21278 | .ErrorUnion => eu: { |
| 21279 | if (maybe_inst_val) |inst_val| { | 21279 | if (maybe_inst_val) |inst_val| { |
| 21280 | switch (inst_val.tag()) { | 21280 | switch (inst_val.tag()) { |
| 21281 | .undef => return sema.addConstUndef(dest_ty), | 21281 | .undef => return sema.addConstUndef(dest_ty), |
| ... | @@ -21284,7 +21284,10 @@ fn coerceExtra( | ... | @@ -21284,7 +21284,10 @@ fn coerceExtra( |
| 21284 | inst_ty.errorUnionPayload(), | 21284 | inst_ty.errorUnionPayload(), |
| 21285 | inst_val.castTag(.eu_payload).?.data, | 21285 | inst_val.castTag(.eu_payload).?.data, |
| 21286 | ); | 21286 | ); |
| 21287 | return sema.wrapErrorUnionPayload(block, dest_ty, payload, inst_src); | 21287 | return sema.wrapErrorUnionPayload(block, dest_ty, payload, inst_src) catch |err| switch (err) { |
| 21288 | error.NotCoercible => break :eu, | ||
| 21289 | else => |e| return e, | ||
| 21290 | }; | ||
| 21288 | }, | 21291 | }, |
| 21289 | else => { | 21292 | else => { |
| 21290 | const error_set = try sema.addConstant( | 21293 | const error_set = try sema.addConstant( |
| ... | @@ -21303,9 +21306,12 @@ fn coerceExtra( | ... | @@ -21303,9 +21306,12 @@ fn coerceExtra( |
| 21303 | .Undefined => { | 21306 | .Undefined => { |
| 21304 | return sema.addConstUndef(dest_ty); | 21307 | return sema.addConstUndef(dest_ty); |
| 21305 | }, | 21308 | }, |
| 21306 | else => { | 21309 | else => eu: { |
| 21307 | // T to E!T | 21310 | // T to E!T |
| 21308 | return sema.wrapErrorUnionPayload(block, dest_ty, inst, inst_src); | 21311 | return sema.wrapErrorUnionPayload(block, dest_ty, inst, inst_src) catch |err| switch (err) { |
| 21312 | error.NotCoercible => break :eu, | ||
| 21313 | else => |e| return e, | ||
| 21314 | }; | ||
| 21309 | }, | 21315 | }, |
| 21310 | }, | 21316 | }, |
| 21311 | .Union => switch (inst_ty.zigTypeTag()) { | 21317 | .Union => switch (inst_ty.zigTypeTag()) { |
| ... | @@ -24795,7 +24801,7 @@ fn wrapErrorUnionPayload( | ... | @@ -24795,7 +24801,7 @@ fn wrapErrorUnionPayload( |
| 24795 | inst_src: LazySrcLoc, | 24801 | inst_src: LazySrcLoc, |
| 24796 | ) !Air.Inst.Ref { | 24802 | ) !Air.Inst.Ref { |
| 24797 | const dest_payload_ty = dest_ty.errorUnionPayload(); | 24803 | const dest_payload_ty = dest_ty.errorUnionPayload(); |
| 24798 | const coerced = try sema.coerce(block, dest_payload_ty, inst, inst_src); | 24804 | const coerced = try sema.coerceExtra(block, dest_payload_ty, inst, inst_src, false, false); |
| 24799 | if (try sema.resolveMaybeUndefVal(block, inst_src, coerced)) |val| { | 24805 | if (try sema.resolveMaybeUndefVal(block, inst_src, coerced)) |val| { |
| 24800 | return sema.addConstant(dest_ty, try Value.Tag.eu_payload.create(sema.arena, val)); | 24806 | return sema.addConstant(dest_ty, try Value.Tag.eu_payload.create(sema.arena, val)); |
| 24801 | } | 24807 | } |
test/cases/compile_errors/issue_2032_compile_diagnostic_string_for_top_level_decl_type.zig created+11| ... | @@ -0,0 +1,11 @@ | ||
| 1 | export fn entry() void { | ||
| 2 | var foo: u32 = @This(){}; | ||
| 3 | _ = foo; | ||
| 4 | } | ||
| 5 | |||
| 6 | // error | ||
| 7 | // backend=stage2 | ||
| 8 | // target=native | ||
| 9 | // | ||
| 10 | // :2:27: error: expected type 'u32', found 'tmp.tmp' | ||
| 11 | // :1:1: note: struct declared here | ||
test/cases/compile_errors/nested_error_set_mismatch.zig created+19| ... | @@ -0,0 +1,19 @@ | ||
| 1 | const NextError = error{NextError}; | ||
| 2 | const OtherError = error{OutOfMemory}; | ||
| 3 | |||
| 4 | export fn entry() void { | ||
| 5 | const a: ?NextError!i32 = foo(); | ||
| 6 | _ = a; | ||
| 7 | } | ||
| 8 | |||
| 9 | fn foo() ?OtherError!i32 { | ||
| 10 | return null; | ||
| 11 | } | ||
| 12 | |||
| 13 | // error | ||
| 14 | // backend=llvm | ||
| 15 | // target=native | ||
| 16 | // | ||
| 17 | // :4:1: error: expected type '?error{NextError}!i32', found '?error{OutOfMemory}!i32' | ||
| 18 | // :4:1: note: optional type child 'error{OutOfMemory}!i32' cannot cast into optional type child 'error{NextError}!i32' | ||
| 19 | // :4:1: note: 'error.OutOfMemory' not a member of destination error set | ||
test/cases/compile_errors/return_invalid_type_from_test.zig+1-1| ... | @@ -5,4 +5,4 @@ test "example" { return 1; } | ... | @@ -5,4 +5,4 @@ test "example" { return 1; } |
| 5 | // target=native | 5 | // target=native |
| 6 | // is_test=1 | 6 | // is_test=1 |
| 7 | // | 7 | // |
| 8 | // :1:25: error: expected type 'void', found 'comptime_int' | 8 | // :1:25: error: expected type '@typeInfo(@typeInfo(@TypeOf(tmp.test.example)).Fn.return_type.?).ErrorUnion.error_set!void', found 'comptime_int' |
| \ No newline at end of file | |||
test/cases/compile_errors/stage1/obj/issue_2032_compile_diagnostic_string_for_top_level_decl_type.zig deleted-10| ... | @@ -1,10 +0,0 @@ | ||
| 1 | export fn entry() void { | ||
| 2 | var foo: u32 = @This(){}; | ||
| 3 | _ = foo; | ||
| 4 | } | ||
| 5 | |||
| 6 | // error | ||
| 7 | // backend=stage1 | ||
| 8 | // target=native | ||
| 9 | // | ||
| 10 | // tmp.zig:2:27: error: type 'u32' does not support array initialization | ||
test/cases/compile_errors/stage1/obj/nested_error_set_mismatch.zig deleted-20| ... | @@ -1,20 +0,0 @@ | ||
| 1 | const NextError = error{NextError}; | ||
| 2 | const OtherError = error{OutOfMemory}; | ||
| 3 | |||
| 4 | export fn entry() void { | ||
| 5 | const a: ?NextError!i32 = foo(); | ||
| 6 | _ = a; | ||
| 7 | } | ||
| 8 | |||
| 9 | fn foo() ?OtherError!i32 { | ||
| 10 | return null; | ||
| 11 | } | ||
| 12 | |||
| 13 | // error | ||
| 14 | // backend=stage1 | ||
| 15 | // target=native | ||
| 16 | // | ||
| 17 | // tmp.zig:5:34: error: expected type '?NextError!i32', found '?OtherError!i32' | ||
| 18 | // tmp.zig:5:34: note: optional type child 'OtherError!i32' cannot cast into optional type child 'NextError!i32' | ||
| 19 | // tmp.zig:5:34: note: error set 'OtherError' cannot cast into error set 'NextError' | ||
| 20 | // tmp.zig:2:26: note: 'error.OutOfMemory' not a member of destination error set | ||
test/cases/compile_errors/stage1/obj/std.fmt_error_for_unused_arguments.zig deleted-9| ... | @@ -1,9 +0,0 @@ | ||
| 1 | export fn entry() void { | ||
| 2 | @import("std").debug.print("{d} {d} {d} {d} {d}", .{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}); | ||
| 3 | } | ||
| 4 | |||
| 5 | // error | ||
| 6 | // backend=stage1 | ||
| 7 | // target=native | ||
| 8 | // | ||
| 9 | // ?:?:?: error: 10 unused arguments in '{d} {d} {d} {d} {d}' | ||
test/cases/compile_errors/stage1/obj/wrong_number_of_arguments.zig deleted-10| ... | @@ -1,10 +0,0 @@ | ||
| 1 | export fn a() void { | ||
| 2 | c(1); | ||
| 3 | } | ||
| 4 | fn c(d: i32, e: i32, f: i32) void { _ = d; _ = e; _ = f; } | ||
| 5 | |||
| 6 | // error | ||
| 7 | // backend=stage1 | ||
| 8 | // target=native | ||
| 9 | // | ||
| 10 | // tmp.zig:2:6: error: expected 3 argument(s), found 1 | ||
test/cases/compile_errors/stage1/obj/wrong_types_given_to_atomic_order_args_in_cmpxchg.zig deleted-10| ... | @@ -1,10 +0,0 @@ | ||
| 1 | export fn entry() void { | ||
| 2 | var x: i32 = 1234; | ||
| 3 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, @as(u32, 1234), @as(u32, 1234))) {} | ||
| 4 | } | ||
| 5 | |||
| 6 | // error | ||
| 7 | // backend=stage1 | ||
| 8 | // target=native | ||
| 9 | // | ||
| 10 | // tmp.zig:3:47: error: expected type 'std.builtin.AtomicOrder', found 'u32' | ||
test/cases/compile_errors/stage1/obj/wrong_types_given_to_export.zig deleted-10| ... | @@ -1,10 +0,0 @@ | ||
| 1 | fn entry() callconv(.C) void { } | ||
| 2 | comptime { | ||
| 3 | @export(entry, .{.name = "entry", .linkage = @as(u32, 1234) }); | ||
| 4 | } | ||
| 5 | |||
| 6 | // error | ||
| 7 | // backend=stage1 | ||
| 8 | // target=native | ||
| 9 | // | ||
| 10 | // tmp.zig:3:59: error: expected type 'std.builtin.GlobalLinkage', found 'comptime_int' | ||
test/cases/compile_errors/std.fmt_error_for_unused_arguments.zig created+9| ... | @@ -0,0 +1,9 @@ | ||
| 1 | export fn entry() void { | ||
| 2 | @import("std").debug.print("{d} {d} {d} {d} {d}", .{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}); | ||
| 3 | } | ||
| 4 | |||
| 5 | // error | ||
| 6 | // backend=llvm | ||
| 7 | // target=native | ||
| 8 | // | ||
| 9 | // :?:?: error: 10 unused arguments in '{d} {d} {d} {d} {d}' | ||
test/cases/compile_errors/wrong_number_of_arguments.zig created+10| ... | @@ -0,0 +1,10 @@ | ||
| 1 | export fn a() void { | ||
| 2 | c(1); | ||
| 3 | } | ||
| 4 | fn c(d: i32, e: i32, f: i32) void { _ = d; _ = e; _ = f; } | ||
| 5 | |||
| 6 | // error | ||
| 7 | // backend=stage2 | ||
| 8 | // target=native | ||
| 9 | // | ||
| 10 | // :2:6: error: expected 3 argument(s), found 1 | ||
test/cases/compile_errors/wrong_types_given_to_atomic_order_args_in_cmpxchg.zig created+11| ... | @@ -0,0 +1,11 @@ | ||
| 1 | export fn entry() void { | ||
| 2 | var x: i32 = 1234; | ||
| 3 | while (!@cmpxchgWeak(i32, &x, 1234, 5678, @as(u32, 1234), @as(u32, 1234))) {} | ||
| 4 | } | ||
| 5 | |||
| 6 | // error | ||
| 7 | // backend=stage2 | ||
| 8 | // target=native | ||
| 9 | // | ||
| 10 | // :3:47: error: expected type 'builtin.AtomicOrder', found 'u32' | ||
| 11 | // :?:?: note: enum declared here | ||
test/cases/compile_errors/wrong_types_given_to_export.zig created+11| ... | @@ -0,0 +1,11 @@ | ||
| 1 | fn entry() callconv(.C) void { } | ||
| 2 | comptime { | ||
| 3 | @export(entry, .{.name = "entry", .linkage = @as(u32, 1234) }); | ||
| 4 | } | ||
| 5 | |||
| 6 | // error | ||
| 7 | // backend=stage2 | ||
| 8 | // target=native | ||
| 9 | // | ||
| 10 | // :3:50: error: expected type 'builtin.GlobalLinkage', found 'u32' | ||
| 11 | // :?:?: note: enum declared here | ||