| author | |
| committer | |
| log | c8c798685f3a7d6454bc06d5f47531ad6f615eb5 |
| tree | a656fc1e402c6b8b4bb6d3b1c6ac9914ed627f71 |
| parent | e2d4709779d23c83edf26db2d92f4a326b790825 |
| parent | d6e3988fe846864a33adf9f5f04d800718b31392 |
| signature |
Minor stage2 fixes22 files changed, 149 insertions(+), 91 deletions(-)
src/Sema.zig+49-15| ... | @@ -2869,7 +2869,16 @@ fn ensureResultUsed( | ... | @@ -2869,7 +2869,16 @@ fn ensureResultUsed( |
| 2869 | }; | 2869 | }; |
| 2870 | return sema.failWithOwnedErrorMsg(block, msg); | 2870 | return sema.failWithOwnedErrorMsg(block, msg); |
| 2871 | }, | 2871 | }, |
| 2872 | else => return sema.fail(block, src, "expression value is ignored", .{}), | 2872 | else => { |
| 2873 | const msg = msg: { | ||
| 2874 | const msg = try sema.errMsg(block, src, "value of type '{}' ignored", .{operand_ty.fmt(sema.mod)}); | ||
| 2875 | errdefer msg.destroy(sema.gpa); | ||
| 2876 | try sema.errNote(block, src, msg, "all non-void values must be used", .{}); | ||
| 2877 | try sema.errNote(block, src, msg, "this error can be suppressed by assigning the value to '_'", .{}); | ||
| 2878 | break :msg msg; | ||
| 2879 | }; | ||
| 2880 | return sema.failWithOwnedErrorMsg(block, msg); | ||
| 2881 | }, | ||
| 2873 | } | 2882 | } |
| 2874 | } | 2883 | } |
| 2875 | 2884 | ||
| ... | @@ -4508,6 +4517,7 @@ fn zirCompileLog( | ... | @@ -4508,6 +4517,7 @@ fn zirCompileLog( |
| 4508 | const arg = try sema.resolveInst(arg_ref); | 4517 | const arg = try sema.resolveInst(arg_ref); |
| 4509 | const arg_ty = sema.typeOf(arg); | 4518 | const arg_ty = sema.typeOf(arg); |
| 4510 | if (try sema.resolveMaybeUndefVal(block, src, arg)) |val| { | 4519 | if (try sema.resolveMaybeUndefVal(block, src, arg)) |val| { |
| 4520 | try sema.resolveLazyValue(block, src, val); | ||
| 4511 | try writer.print("@as({}, {})", .{ | 4521 | try writer.print("@as({}, {})", .{ |
| 4512 | arg_ty.fmt(sema.mod), val.fmtValue(arg_ty, sema.mod), | 4522 | arg_ty.fmt(sema.mod), val.fmtValue(arg_ty, sema.mod), |
| 4513 | }); | 4523 | }); |
| ... | @@ -5498,7 +5508,7 @@ fn analyzeCall( | ... | @@ -5498,7 +5508,7 @@ fn analyzeCall( |
| 5498 | // TODO add error note: declared here | 5508 | // TODO add error note: declared here |
| 5499 | return sema.fail( | 5509 | return sema.fail( |
| 5500 | block, | 5510 | block, |
| 5501 | func_src, | 5511 | call_src, |
| 5502 | "expected {d} argument(s), found {d}", | 5512 | "expected {d} argument(s), found {d}", |
| 5503 | .{ fn_params_len, uncasted_args.len }, | 5513 | .{ fn_params_len, uncasted_args.len }, |
| 5504 | ); | 5514 | ); |
| ... | @@ -8918,6 +8928,10 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -8918,6 +8928,10 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8918 | 8928 | ||
| 8919 | if (special_prong == .@"else" and seen_errors.count() == operand_ty.errorSetNames().len) { | 8929 | if (special_prong == .@"else" and seen_errors.count() == operand_ty.errorSetNames().len) { |
| 8920 | 8930 | ||
| 8931 | // TODO re-enable if defer implementation is improved | ||
| 8932 | // https://github.com/ziglang/zig/issues/11798 | ||
| 8933 | if (true) break :else_validation; | ||
| 8934 | |||
| 8921 | // In order to enable common patterns for generic code allow simple else bodies | 8935 | // In order to enable common patterns for generic code allow simple else bodies |
| 8922 | // else => unreachable, | 8936 | // else => unreachable, |
| 8923 | // else => return, | 8937 | // else => return, |
| ... | @@ -20592,6 +20606,14 @@ fn tupleFieldPtr( | ... | @@ -20592,6 +20606,14 @@ fn tupleFieldPtr( |
| 20592 | .@"addrspace" = tuple_ptr_ty.ptrAddressSpace(), | 20606 | .@"addrspace" = tuple_ptr_ty.ptrAddressSpace(), |
| 20593 | }); | 20607 | }); |
| 20594 | 20608 | ||
| 20609 | if (tuple_ty.structFieldValueComptime(field_index)) |default_val| { | ||
| 20610 | const val = try Value.Tag.comptime_field_ptr.create(sema.arena, .{ | ||
| 20611 | .field_ty = field_ty, | ||
| 20612 | .field_val = default_val, | ||
| 20613 | }); | ||
| 20614 | return sema.addConstant(ptr_field_ty, val); | ||
| 20615 | } | ||
| 20616 | |||
| 20595 | if (try sema.resolveMaybeUndefVal(block, tuple_ptr_src, tuple_ptr)) |tuple_ptr_val| { | 20617 | if (try sema.resolveMaybeUndefVal(block, tuple_ptr_src, tuple_ptr)) |tuple_ptr_val| { |
| 20596 | return sema.addConstant( | 20618 | return sema.addConstant( |
| 20597 | ptr_field_ty, | 20619 | ptr_field_ty, |
| ... | @@ -20603,14 +20625,6 @@ fn tupleFieldPtr( | ... | @@ -20603,14 +20625,6 @@ fn tupleFieldPtr( |
| 20603 | ); | 20625 | ); |
| 20604 | } | 20626 | } |
| 20605 | 20627 | ||
| 20606 | if (tuple_ty.structFieldValueComptime(field_index)) |default_val| { | ||
| 20607 | const val = try Value.Tag.comptime_field_ptr.create(sema.arena, .{ | ||
| 20608 | .field_ty = field_ty, | ||
| 20609 | .field_val = default_val, | ||
| 20610 | }); | ||
| 20611 | return sema.addConstant(ptr_field_ty, val); | ||
| 20612 | } | ||
| 20613 | |||
| 20614 | if (!init) { | 20628 | if (!init) { |
| 20615 | try sema.validateRuntimeElemAccess(block, field_index_src, field_ty, tuple_ty, tuple_ptr_src); | 20629 | try sema.validateRuntimeElemAccess(block, field_index_src, field_ty, tuple_ty, tuple_ptr_src); |
| 20616 | } | 20630 | } |
| ... | @@ -21354,7 +21368,7 @@ fn coerceExtra( | ... | @@ -21354,7 +21368,7 @@ fn coerceExtra( |
| 21354 | else => {}, | 21368 | else => {}, |
| 21355 | }, | 21369 | }, |
| 21356 | .ErrorUnion => switch (inst_ty.zigTypeTag()) { | 21370 | .ErrorUnion => switch (inst_ty.zigTypeTag()) { |
| 21357 | .ErrorUnion => { | 21371 | .ErrorUnion => eu: { |
| 21358 | if (maybe_inst_val) |inst_val| { | 21372 | if (maybe_inst_val) |inst_val| { |
| 21359 | switch (inst_val.tag()) { | 21373 | switch (inst_val.tag()) { |
| 21360 | .undef => return sema.addConstUndef(dest_ty), | 21374 | .undef => return sema.addConstUndef(dest_ty), |
| ... | @@ -21363,7 +21377,10 @@ fn coerceExtra( | ... | @@ -21363,7 +21377,10 @@ fn coerceExtra( |
| 21363 | inst_ty.errorUnionPayload(), | 21377 | inst_ty.errorUnionPayload(), |
| 21364 | inst_val.castTag(.eu_payload).?.data, | 21378 | inst_val.castTag(.eu_payload).?.data, |
| 21365 | ); | 21379 | ); |
| 21366 | return sema.wrapErrorUnionPayload(block, dest_ty, payload, inst_src); | 21380 | return sema.wrapErrorUnionPayload(block, dest_ty, payload, inst_src) catch |err| switch (err) { |
| 21381 | error.NotCoercible => break :eu, | ||
| 21382 | else => |e| return e, | ||
| 21383 | }; | ||
| 21367 | }, | 21384 | }, |
| 21368 | else => { | 21385 | else => { |
| 21369 | const error_set = try sema.addConstant( | 21386 | const error_set = try sema.addConstant( |
| ... | @@ -21382,9 +21399,12 @@ fn coerceExtra( | ... | @@ -21382,9 +21399,12 @@ fn coerceExtra( |
| 21382 | .Undefined => { | 21399 | .Undefined => { |
| 21383 | return sema.addConstUndef(dest_ty); | 21400 | return sema.addConstUndef(dest_ty); |
| 21384 | }, | 21401 | }, |
| 21385 | else => { | 21402 | else => eu: { |
| 21386 | // T to E!T | 21403 | // T to E!T |
| 21387 | return sema.wrapErrorUnionPayload(block, dest_ty, inst, inst_src); | 21404 | return sema.wrapErrorUnionPayload(block, dest_ty, inst, inst_src) catch |err| switch (err) { |
| 21405 | error.NotCoercible => break :eu, | ||
| 21406 | else => |e| return e, | ||
| 21407 | }; | ||
| 21388 | }, | 21408 | }, |
| 21389 | }, | 21409 | }, |
| 21390 | .Union => switch (inst_ty.zigTypeTag()) { | 21410 | .Union => switch (inst_ty.zigTypeTag()) { |
| ... | @@ -23334,6 +23354,16 @@ fn beginComptimePtrLoad( | ... | @@ -23334,6 +23354,16 @@ fn beginComptimePtrLoad( |
| 23334 | break :blk deref; | 23354 | break :blk deref; |
| 23335 | }, | 23355 | }, |
| 23336 | 23356 | ||
| 23357 | .comptime_field_ptr => blk: { | ||
| 23358 | const comptime_field_ptr = ptr_val.castTag(.comptime_field_ptr).?.data; | ||
| 23359 | break :blk ComptimePtrLoadKit{ | ||
| 23360 | .parent = null, | ||
| 23361 | .pointee = .{ .ty = comptime_field_ptr.field_ty, .val = comptime_field_ptr.field_val }, | ||
| 23362 | .is_mutable = false, | ||
| 23363 | .ty_without_well_defined_layout = comptime_field_ptr.field_ty, | ||
| 23364 | }; | ||
| 23365 | }, | ||
| 23366 | |||
| 23337 | .opt_payload_ptr, | 23367 | .opt_payload_ptr, |
| 23338 | .eu_payload_ptr, | 23368 | .eu_payload_ptr, |
| 23339 | => blk: { | 23369 | => blk: { |
| ... | @@ -24864,7 +24894,7 @@ fn wrapErrorUnionPayload( | ... | @@ -24864,7 +24894,7 @@ fn wrapErrorUnionPayload( |
| 24864 | inst_src: LazySrcLoc, | 24894 | inst_src: LazySrcLoc, |
| 24865 | ) !Air.Inst.Ref { | 24895 | ) !Air.Inst.Ref { |
| 24866 | const dest_payload_ty = dest_ty.errorUnionPayload(); | 24896 | const dest_payload_ty = dest_ty.errorUnionPayload(); |
| 24867 | const coerced = try sema.coerce(block, dest_payload_ty, inst, inst_src); | 24897 | const coerced = try sema.coerceExtra(block, dest_payload_ty, inst, inst_src, false, false); |
| 24868 | if (try sema.resolveMaybeUndefVal(block, inst_src, coerced)) |val| { | 24898 | if (try sema.resolveMaybeUndefVal(block, inst_src, coerced)) |val| { |
| 24869 | return sema.addConstant(dest_ty, try Value.Tag.eu_payload.create(sema.arena, val)); | 24899 | return sema.addConstant(dest_ty, try Value.Tag.eu_payload.create(sema.arena, val)); |
| 24870 | } | 24900 | } |
| ... | @@ -25523,6 +25553,10 @@ fn resolveLazyValue( | ... | @@ -25523,6 +25553,10 @@ fn resolveLazyValue( |
| 25523 | const ty = val.castTag(.lazy_align).?.data; | 25553 | const ty = val.castTag(.lazy_align).?.data; |
| 25524 | return sema.resolveTypeLayout(block, src, ty); | 25554 | return sema.resolveTypeLayout(block, src, ty); |
| 25525 | }, | 25555 | }, |
| 25556 | .lazy_size => { | ||
| 25557 | const ty = val.castTag(.lazy_size).?.data; | ||
| 25558 | return sema.resolveTypeLayout(block, src, ty); | ||
| 25559 | }, | ||
| 25526 | else => return, | 25560 | else => return, |
| 25527 | } | 25561 | } |
| 25528 | } | 25562 | } |
test/cases/compile_errors/compile_log.zig+5| ... | @@ -6,9 +6,14 @@ fn bar(a: i32, b: []const u8) void { | ... | @@ -6,9 +6,14 @@ fn bar(a: i32, b: []const u8) void { |
| 6 | @compileLog("a", a, "b", b); | 6 | @compileLog("a", a, "b", b); |
| 7 | @compileLog("end",); | 7 | @compileLog("end",); |
| 8 | } | 8 | } |
| 9 | export fn baz() void { | ||
| 10 | const S = struct { a: u32 }; | ||
| 11 | @compileLog(@sizeOf(S)); | ||
| 12 | } | ||
| 9 | 13 | ||
| 10 | // error | 14 | // error |
| 11 | // backend=llvm | 15 | // backend=llvm |
| 12 | // target=native | 16 | // target=native |
| 13 | // | 17 | // |
| 14 | // :5:5: error: found compile log statement | 18 | // :5:5: error: found compile log statement |
| 19 | // :11:5: note: also here |
test/cases/compile_errors/ignored_assert-err-ok_return_value.zig+3-1| ... | @@ -7,4 +7,6 @@ fn bar() anyerror!i32 { return 0; } | ... | @@ -7,4 +7,6 @@ fn bar() anyerror!i32 { return 0; } |
| 7 | // backend=stage2 | 7 | // backend=stage2 |
| 8 | // target=native | 8 | // target=native |
| 9 | // | 9 | // |
| 10 | // :2:11: error: expression value is ignored | 10 | // :2:11: error: value of type 'i32' ignored |
| 11 | // :2:11: note: all non-void values must be used | ||
| 12 | // :2:11: note: this error can be suppressed by assigning the value to '_' |
test/cases/compile_errors/ignored_comptime_statement_value.zig+3-1| ... | @@ -6,4 +6,6 @@ export fn foo() void { | ... | @@ -6,4 +6,6 @@ export fn foo() void { |
| 6 | // backend=stage2 | 6 | // backend=stage2 |
| 7 | // target=native | 7 | // target=native |
| 8 | // | 8 | // |
| 9 | // :2:15: error: expression value is ignored | 9 | // :2:15: error: value of type 'comptime_int' ignored |
| 10 | // :2:15: note: all non-void values must be used | ||
| 11 | // :2:15: note: this error can be suppressed by assigning the value to '_' |
test/cases/compile_errors/ignored_comptime_value.zig+3-1| ... | @@ -6,4 +6,6 @@ export fn foo() void { | ... | @@ -6,4 +6,6 @@ export fn foo() void { |
| 6 | // backend=stage2 | 6 | // backend=stage2 |
| 7 | // target=native | 7 | // target=native |
| 8 | // | 8 | // |
| 9 | // :2:5: error: expression value is ignored | 9 | // :2:5: error: value of type 'comptime_int' ignored |
| 10 | // :2:5: note: all non-void values must be used | ||
| 11 | // :2:5: note: this error can be suppressed by assigning the value to '_' |
test/cases/compile_errors/ignored_deferred_statement_value.zig+3-1| ... | @@ -6,4 +6,6 @@ export fn foo() void { | ... | @@ -6,4 +6,6 @@ export fn foo() void { |
| 6 | // backend=stage2 | 6 | // backend=stage2 |
| 7 | // target=native | 7 | // target=native |
| 8 | // | 8 | // |
| 9 | // :2:12: error: expression value is ignored | 9 | // :2:12: error: value of type 'comptime_int' ignored |
| 10 | // :2:12: note: all non-void values must be used | ||
| 11 | // :2:12: note: this error can be suppressed by assigning the value to '_' |
test/cases/compile_errors/ignored_return_value.zig+3-1| ... | @@ -7,4 +7,6 @@ fn bar() i32 { return 0; } | ... | @@ -7,4 +7,6 @@ fn bar() i32 { return 0; } |
| 7 | // backend=stage2 | 7 | // backend=stage2 |
| 8 | // target=native | 8 | // target=native |
| 9 | // | 9 | // |
| 10 | // :2:8: error: expression value is ignored | 10 | // :2:8: error: value of type 'i32' ignored |
| 11 | // :2:8: note: all non-void values must be used | ||
| 12 | // :2:8: note: this error can be suppressed by assigning the value to '_' |
test/cases/compile_errors/ignored_statement_value.zig+3-1| ... | @@ -6,4 +6,6 @@ export fn foo() void { | ... | @@ -6,4 +6,6 @@ export fn foo() void { |
| 6 | // backend=stage2 | 6 | // backend=stage2 |
| 7 | // target=native | 7 | // target=native |
| 8 | // | 8 | // |
| 9 | // :2:5: error: expression value is ignored | 9 | // :2:5: error: value of type 'comptime_int' ignored |
| 10 | // :2:5: note: all non-void values must be used | ||
| 11 | // :2:5: note: this error can be suppressed by assigning the value to '_' |
test/cases/compile_errors/invalid_store_to_comptime_field.zig+5| ... | @@ -40,6 +40,10 @@ pub export fn entry4() void { | ... | @@ -40,6 +40,10 @@ pub export fn entry4() void { |
| 40 | }; | 40 | }; |
| 41 | _ = U.foo(.{ .foo = 2, .bar = 2 }); | 41 | _ = U.foo(.{ .foo = 2, .bar = 2 }); |
| 42 | } | 42 | } |
| 43 | pub export fn entry5() void { | ||
| 44 | comptime var y = .{ 1, 2}; | ||
| 45 | y = .{ 3, 4 }; | ||
| 46 | } | ||
| 43 | // pub export fn entry5() void { | 47 | // pub export fn entry5() void { |
| 44 | // var x: u32 = 15; | 48 | // var x: u32 = 15; |
| 45 | // const T = @TypeOf(.{ @as(i32, -1234), @as(u32, 5678), x }); | 49 | // const T = @TypeOf(.{ @as(i32, -1234), @as(u32, 5678), x }); |
| ... | @@ -60,3 +64,4 @@ pub export fn entry4() void { | ... | @@ -60,3 +64,4 @@ pub export fn entry4() void { |
| 60 | // :31:19: error: value stored in comptime field does not match the default value of the field | 64 | // :31:19: error: value stored in comptime field does not match the default value of the field |
| 61 | // :25:29: note: default value set here | 65 | // :25:29: note: default value set here |
| 62 | // :41:16: error: value stored in comptime field does not match the default value of the field | 66 | // :41:16: error: value stored in comptime field does not match the default value of the field |
| 67 | // :45:12: error: value stored in comptime field does not match the default value of the field |
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 | ||