authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-11-11 07:27:31+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-11-19 09:56:51+00:00
log21fa187abc2a06c9bd5cfe4355c5edbfb3177f6b
treeaab7cc16498184bac0fd8b6d5443f7bd606e7bf8
parent2c1acb618027939c0812bc87a432b51632127717
signaturelock-open Commit is signed but in an unrecognized format.

test: update cases to silence 'var is never mutated' errors


290 files changed, 695 insertions(+), 513 deletions(-)

test/cases/adding_numbers_at_runtime_and_comptime.2.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var x: usize = 3;
3 _ = &x;
34 const y = add(1, 2, x);
45 if (y - 6 != 0) unreachable;
56}
test/cases/array_in_anon_struct.zig+1
......@@ -2,6 +2,7 @@ const std = @import("std");
22
33noinline fn outer() u32 {
44 var a: u32 = 42;
5 _ = &a;
56 return inner(.{
67 .unused = a,
78 .value = [1]u32{0},
test/cases/assert_function.17.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var i: u64 = 0xFFEEDDCCBBAA9988;
3 _ = &i;
34 assert(i == 0xFFEEDDCCBBAA9988);
45}
56
test/cases/bad_inferred_variable_type.zig+1-1
......@@ -1,6 +1,6 @@
11pub fn main() void {
22 var x = null;
3 _ = x;
3 _ = &x;
44}
55
66// error
test/cases/binary_operands.1.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var i: i32 = 2147483647;
3 _ = &i;
34 if (i +% 1 != -2147483648) unreachable;
45 return;
56}
test/cases/binary_operands.10.zig+1
......@@ -2,6 +2,7 @@ pub fn main() void {
22 var i: u32 = 5;
33 i *= 7;
44 var result: u32 = foo(i, 10);
5 _ = &result;
56 if (result != 350) unreachable;
67 return;
78}
test/cases/binary_operands.11.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var i: i32 = 2147483647;
3 _ = &i;
34 const result = i *% 2;
45 if (result != -2) unreachable;
56 return;
test/cases/binary_operands.12.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var i: u3 = 3;
3 _ = &i;
34 if (i *% 3 != 1) unreachable;
45 return;
56}
test/cases/binary_operands.13.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var i: i4 = 3;
3 _ = &i;
34 if (i *% 3 != -7) unreachable;
45 return;
56}
test/cases/binary_operands.14.zig+1-1
......@@ -1,7 +1,7 @@
11pub fn main() void {
22 var i: u32 = 352;
33 i /= 7; // i = 50
4 var result: u32 = foo(i, 7);
4 const result: u32 = foo(i, 7);
55 if (result != 7) unreachable;
66 return;
77}
test/cases/binary_operands.2.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var i: i4 = 7;
3 _ = &i;
34 if (i +% 1 != -8) unreachable;
45 return;
56}
test/cases/binary_operands.3.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() u8 {
22 var i: u8 = 255;
3 _ = &i;
34 return i +% 1;
45}
56
test/cases/binary_operands.4.zig+1-1
......@@ -1,7 +1,7 @@
11pub fn main() u8 {
22 var i: u8 = 5;
33 i += 20;
4 var result: u8 = foo(i, 10);
4 const result: u8 = foo(i, 10);
55 return result - 35;
66}
77fn foo(x: u8, y: u8) u8 {
test/cases/binary_operands.6.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var i: i32 = -2147483648;
3 _ = &i;
34 if (i -% 1 != 2147483647) unreachable;
45 return;
56}
test/cases/binary_operands.7.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var i: i7 = -64;
3 _ = &i;
34 if (i -% 1 != 63) unreachable;
45 return;
56}
test/cases/binary_operands.8.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var i: u4 = 0;
3 _ = &i;
34 if (i -% 1 != 15) unreachable;
45}
56
test/cases/binary_operands.9.zig+1
......@@ -2,6 +2,7 @@ pub fn main() u8 {
22 var i: u8 = 5;
33 i -= 3;
44 var result: u8 = foo(i, 10);
5 _ = &result;
56 return result - 8;
67}
78fn foo(x: u8, y: u8) u8 {
test/cases/comparison_of_non-tagged_union_and_enum_literal.zig+2-1
......@@ -2,7 +2,8 @@ export fn entry() void {
22 const U = union { A: u32, B: u64 };
33 var u = U{ .A = 42 };
44 var ok = u == .A;
5 _ = ok;
5 _ = &u;
6 _ = &ok;
67}
78
89// error
test/cases/compile_errors/AstGen_comptime_known_struct_is_resolved_before_error.zig+1-1
......@@ -6,7 +6,7 @@ const S2 = struct {
66};
77pub export fn entry() void {
88 var s: S1 = undefined;
9 _ = s;
9 _ = &s;
1010}
1111
1212// error
test/cases/compile_errors/C_pointer_pointing_to_non_C_ABI_compatible_type_or_has_align_attr.zig+1-1
......@@ -1,7 +1,7 @@
11const Foo = struct { a: u32 };
22export fn a() void {
33 const T = [*c]Foo;
4 var t: T = undefined;
4 const t: T = undefined;
55 _ = t;
66}
77
test/cases/compile_errors/C_pointer_to_anyopaque.zig+1-1
......@@ -1,7 +1,7 @@
11export fn a() void {
22 var x: *anyopaque = undefined;
33 var y: [*c]anyopaque = x;
4 _ = y;
4 _ = .{ &x, &y };
55}
66
77// error
test/cases/compile_errors/accessing_runtime_parameter_from_outer_function.zig+2-2
......@@ -7,8 +7,8 @@ fn outer(y: u32) *const fn (u32) u32 {
77 return st.get;
88}
99export fn entry() void {
10 var func = outer(10);
11 var x = func(3);
10 const func = outer(10);
11 const x = func(3);
1212 _ = x;
1313}
1414
test/cases/compile_errors/add_on_undefined_value.zig+1-1
......@@ -1,5 +1,5 @@
11comptime {
2 var a: i64 = undefined;
2 const a: i64 = undefined;
33 _ = a + a;
44}
55
test/cases/compile_errors/alignment_of_enum_field_specified.zig+1-1
......@@ -6,7 +6,7 @@ const Number = enum {
66// zig fmt: on
77
88export fn entry1() void {
9 var x: Number = undefined;
9 const x: Number = undefined;
1010 _ = x;
1111}
1212
test/cases/compile_errors/ambiguous_coercion_of_division_operands.zig+6-6
......@@ -1,17 +1,17 @@
11export fn entry1() void {
2 var f: f32 = 54.0 / 5;
2 const f: f32 = 54.0 / 5;
33 _ = f;
44}
55export fn entry2() void {
6 var f: f32 = 54 / 5.0;
6 const f: f32 = 54 / 5.0;
77 _ = f;
88}
99export fn entry3() void {
10 var f: f32 = 55.0 / 5;
10 const f: f32 = 55.0 / 5;
1111 _ = f;
1212}
1313export fn entry4() void {
14 var f: f32 = 55 / 5.0;
14 const f: f32 = 55 / 5.0;
1515 _ = f;
1616}
1717
......@@ -19,5 +19,5 @@ export fn entry4() void {
1919// backend=stage2
2020// target=native
2121//
22// :2:23: error: ambiguous coercion of division operands 'comptime_float' and 'comptime_int'; non-zero remainder '4'
23// :6:21: error: ambiguous coercion of division operands 'comptime_int' and 'comptime_float'; non-zero remainder '4'
22// :2:25: error: ambiguous coercion of division operands 'comptime_float' and 'comptime_int'; non-zero remainder '4'
23// :6:23: error: ambiguous coercion of division operands 'comptime_int' and 'comptime_float'; non-zero remainder '4'
test/cases/compile_errors/and_on_undefined_value.zig+2-1
......@@ -1,5 +1,6 @@
11comptime {
22 var a: bool = undefined;
3 _ = &a;
34 _ = a and a;
45}
56
......@@ -7,4 +8,4 @@ comptime {
78// backend=stage2
89// target=native
910//
10// :3:9: error: use of undefined value here causes undefined behavior
11// :4:9: error: use of undefined value here causes undefined behavior
test/cases/compile_errors/array_access_of_non_array.zig+1-1
......@@ -3,7 +3,7 @@ export fn f() void {
33 bad[0] = bad[0];
44}
55export fn g() void {
6 var bad: bool = undefined;
6 const bad: bool = undefined;
77 _ = bad[0];
88}
99
test/cases/compile_errors/array_access_of_type.zig+1-1
......@@ -1,6 +1,6 @@
11export fn foo() void {
22 var b: u8[40] = undefined;
3 _ = b;
3 _ = &b;
44}
55
66// error
test/cases/compile_errors/array_access_with_non_integer_index.zig+3-1
......@@ -2,11 +2,13 @@ export fn f() void {
22 var array = "aoeu";
33 var bad = false;
44 array[bad] = array[bad];
5 _ = &bad;
56}
67export fn g() void {
78 var array = "aoeu";
89 var bad = false;
910 _ = array[bad];
11 _ = .{ &array, &bad };
1012}
1113
1214// error
......@@ -14,4 +16,4 @@ export fn g() void {
1416// target=native
1517//
1618// :4:11: error: expected type 'usize', found 'bool'
17// :9:15: error: expected type 'usize', found 'bool'
19// :10:15: error: expected type 'usize', found 'bool'
test/cases/compile_errors/array_init_invalid_elem_count.zig+6-6
......@@ -2,27 +2,27 @@ const V = @Vector(8, u8);
22const A = [8]u8;
33comptime {
44 var v: V = V{1};
5 _ = v;
5 _ = &v;
66}
77comptime {
88 var v: V = V{};
9 _ = v;
9 _ = &v;
1010}
1111comptime {
1212 var a: A = A{1};
13 _ = a;
13 _ = &a;
1414}
1515comptime {
1616 var a: A = A{};
17 _ = a;
17 _ = &a;
1818}
1919pub export fn entry1() void {
2020 var bla: V = .{ 1, 2, 3, 4 };
21 _ = bla;
21 _ = &bla;
2222}
2323pub export fn entry2() void {
2424 var bla: A = .{ 1, 2, 3, 4 };
25 _ = bla;
25 _ = &bla;
2626}
2727const S = struct {
2828 list: [2]u8 = .{0},
test/cases/compile_errors/assign_inline_fn_to_non-comptime_var.zig+1-1
......@@ -1,6 +1,6 @@
11export fn entry() void {
22 var a = &b;
3 _ = a;
3 _ = &a;
44}
55inline fn b() void {}
66
test/cases/compile_errors/assign_local_bad_coercion.zig+1-1
......@@ -9,7 +9,7 @@ export fn constEntry() u32 {
99
1010export fn varEntry() u32 {
1111 var x: u32 = g();
12 return x;
12 return (&x).*;
1313}
1414
1515// error
test/cases/compile_errors/assign_too_big_number_to_u16.zig+2-2
......@@ -1,5 +1,5 @@
11export fn foo() void {
2 var vga_mem: u16 = 0xB8000;
2 const vga_mem: u16 = 0xB8000;
33 _ = vga_mem;
44}
55
......@@ -7,4 +7,4 @@ export fn foo() void {
77// backend=stage2
88// target=native
99//
10// :2:24: error: type 'u16' cannot represent integer value '753664'
10// :2:26: error: type 'u16' cannot represent integer value '753664'
test/cases/compile_errors/assigning_to_struct_or_union_fields_that_are_not_optionals_with_a_function_that_returns_an_optional.zig+2-2
......@@ -10,8 +10,8 @@ const S = struct {
1010export fn entry() void {
1111 var u = U{ .Ye = maybe(false) };
1212 var s = S{ .num = maybe(false) };
13 _ = u;
14 _ = s;
13 _ = &u;
14 _ = &s;
1515}
1616
1717// error
test/cases/compile_errors/async/Frame_of_generic_function.zig+2-2
......@@ -1,10 +1,10 @@
11export fn entry() void {
22 var frame: @Frame(func) = undefined;
3 _ = frame;
3 _ = &frame;
44}
55fn func(comptime T: type) void {
66 var x: T = undefined;
7 _ = x;
7 _ = &x;
88}
99
1010// error
test/cases/compile_errors/async/async_function_depends_on_its_own_frame.zig+1-1
......@@ -3,7 +3,7 @@ export fn entry() void {
33}
44fn amain() callconv(.Async) void {
55 var x: [@sizeOf(@Frame(amain))]u8 = undefined;
6 _ = x;
6 _ = &x;
77}
88
99// error
test/cases/compile_errors/async/async_function_indirectly_depends_on_its_own_frame.zig+1-1
......@@ -6,7 +6,7 @@ fn amain() callconv(.Async) void {
66}
77fn other() void {
88 var x: [@sizeOf(@Frame(amain))]u8 = undefined;
9 _ = x;
9 _ = &x;
1010}
1111
1212// error
test/cases/compile_errors/async/bad_alignment_in_asynccall.zig+1
......@@ -2,6 +2,7 @@ export fn entry() void {
22 var ptr: fn () callconv(.Async) void = func;
33 var bytes: [64]u8 = undefined;
44 _ = @asyncCall(&bytes, {}, ptr, .{});
5 _ = &ptr;
56}
67fn func() callconv(.Async) void {}
78
test/cases/compile_errors/async/const_frame_cast_to_anyframe.zig+1-1
......@@ -5,7 +5,7 @@ export fn a() void {
55export fn b() void {
66 const f = async func();
77 var x: anyframe = &f;
8 _ = x;
8 _ = &x;
99}
1010fn func() void {
1111 suspend {}
test/cases/compile_errors/async/indirect_recursion_of_async_functions_detected.zig+4-4
......@@ -12,7 +12,7 @@ fn rangeSum(x: i32) i32 {
1212 frame = null;
1313
1414 if (x == 0) return 0;
15 var child = rangeSumIndirect(x - 1);
15 const child = rangeSumIndirect(x - 1);
1616 return child + 1;
1717}
1818
......@@ -23,7 +23,7 @@ fn rangeSumIndirect(x: i32) i32 {
2323 frame = null;
2424
2525 if (x == 0) return 0;
26 var child = rangeSum(x - 1);
26 const child = rangeSum(x - 1);
2727 return child + 1;
2828}
2929
......@@ -32,5 +32,5 @@ fn rangeSumIndirect(x: i32) i32 {
3232// target=native
3333//
3434// tmp.zig:8:1: error: '@Frame(rangeSum)' depends on itself
35// tmp.zig:15:33: note: when analyzing type '@Frame(rangeSum)' here
36// tmp.zig:26:25: note: when analyzing type '@Frame(rangeSumIndirect)' here
35// tmp.zig:15:35: note: when analyzing type '@Frame(rangeSum)' here
36// tmp.zig:28:25: note: when analyzing type '@Frame(rangeSumIndirect)' here
test/cases/compile_errors/async/invalid_suspend_in_exported_function.zig+1-1
......@@ -1,7 +1,7 @@
11export fn entry() void {
22 var frame = async func();
33 var result = await frame;
4 _ = result;
4 _ = &result;
55}
66fn func() void {
77 suspend {}
test/cases/compile_errors/async/non_async_function_pointer_passed_to_asyncCall.zig+1
......@@ -2,6 +2,7 @@ export fn entry() void {
22 var ptr = afunc;
33 var bytes: [100]u8 align(16) = undefined;
44 _ = @asyncCall(&bytes, {}, ptr, .{});
5 _ = &ptr;
56}
67fn afunc() void {}
78
test/cases/compile_errors/async/prevent_bad_implicit_casting_of_anyframe_types.zig+3-3
......@@ -1,17 +1,17 @@
11export fn a() void {
22 var x: anyframe = undefined;
33 var y: anyframe->i32 = x;
4 _ = y;
4 _ = .{ &x, &y };
55}
66export fn b() void {
77 var x: i32 = undefined;
88 var y: anyframe->i32 = x;
9 _ = y;
9 _ = .{ &x, &y };
1010}
1111export fn c() void {
1212 var x: @Frame(func) = undefined;
1313 var y: anyframe->i32 = &x;
14 _ = y;
14 _ = .{ &x, &y };
1515}
1616fn func() void {}
1717
test/cases/compile_errors/async/runtime-known_async_function_called.zig+1
......@@ -4,6 +4,7 @@ export fn entry() void {
44fn amain() void {
55 var ptr = afunc;
66 _ = ptr();
7 _ = &ptr;
78}
89fn afunc() callconv(.Async) void {}
910
test/cases/compile_errors/async/runtime-known_function_called_with_async_keyword.zig+1
......@@ -1,6 +1,7 @@
11export fn entry() void {
22 var ptr = afunc;
33 _ = async ptr();
4 _ = &ptr;
45}
56
67fn afunc() callconv(.Async) void {}
test/cases/compile_errors/attempted_implicit_cast_from_const_T_to_array_len_1_T.zig+2-2
......@@ -1,9 +1,9 @@
1export fn entry(byte: u8) void {
1export fn entry() void {
22 const w: i32 = 1234;
33 var x: *const i32 = &w;
44 var y: *[1]i32 = x;
55 y[0] += 1;
6 _ = byte;
6 _ = &x;
77}
88
99// error
test/cases/compile_errors/bad_alignment_in_implicit_cast_from_array_pointer_to_slice.zig+3-3
......@@ -1,6 +1,6 @@
11export fn a() void {
22 var x: [10]u8 = undefined;
3 var y: []align(16) u8 = &x;
3 const y: []align(16) u8 = &x;
44 _ = y;
55}
66
......@@ -8,5 +8,5 @@ export fn a() void {
88// backend=stage2
99// target=native
1010//
11// :3:29: error: expected type '[]align(16) u8', found '*[10]u8'
12// :3:29: note: pointer alignment '1' cannot cast into pointer alignment '16'
11// :3:31: error: expected type '[]align(16) u8', found '*[10]u8'
12// :3:31: note: pointer alignment '1' cannot cast into pointer alignment '16'
test/cases/compile_errors/bad_alignment_type.zig+4-4
......@@ -1,9 +1,9 @@
11export fn entry1() void {
2 var x: []align(true) i32 = undefined;
2 const x: []align(true) i32 = undefined;
33 _ = x;
44}
55export fn entry2() void {
6 var x: *align(@as(f64, 12.34)) i32 = undefined;
6 const x: *align(@as(f64, 12.34)) i32 = undefined;
77 _ = x;
88}
99
......@@ -11,5 +11,5 @@ export fn entry2() void {
1111// backend=stage2
1212// target=native
1313//
14// :2:20: error: expected type 'u32', found 'bool'
15// :6:19: error: fractional component prevents float value '12.34' from coercion to type 'u32'
14// :2:22: error: expected type 'u32', found 'bool'
15// :6:21: error: fractional component prevents float value '12.34' from coercion to type 'u32'
test/cases/compile_errors/bad_usage_of_call.zig+3-2
......@@ -11,7 +11,7 @@ export fn entry4() void {
1111 @call(.never_inline, bar, .{});
1212}
1313export fn entry5(c: bool) void {
14 var baz = if (c) &baz1 else &baz2;
14 const baz = if (c) &baz1 else &baz2;
1515 @call(.compile_time, baz, .{});
1616}
1717export fn entry6() void {
......@@ -22,6 +22,7 @@ export fn entry7() void {
2222}
2323pub export fn entry() void {
2424 var call_me: *const fn () void = undefined;
25 _ = &call_me;
2526 @call(.always_inline, call_me, .{});
2627}
2728
......@@ -45,4 +46,4 @@ noinline fn dummy2() void {}
4546// :15:26: error: modifier 'compile_time' requires a comptime-known function
4647// :18:9: error: 'always_inline' call of noinline function
4748// :21:9: error: 'always_inline' call of noinline function
48// :25:27: error: modifier 'always_inline' requires a comptime-known function
49// :26:27: error: modifier 'always_inline' requires a comptime-known function
test/cases/compile_errors/binary_OR_operator_on_error_sets.zig+1-1
......@@ -1,7 +1,7 @@
11pub const A = error.A;
22pub const AB = A | error.B;
33export fn entry() void {
4 var x: AB = undefined;
4 const x: AB = undefined;
55 _ = x;
66}
77
test/cases/compile_errors/bitCast_same_size_but_bit_count_mismatch.zig+2-2
......@@ -1,5 +1,5 @@
11export fn entry(byte: u8) void {
2 var oops: u7 = @bitCast(byte);
2 const oops: u7 = @bitCast(byte);
33 _ = oops;
44}
55
......@@ -7,4 +7,4 @@ export fn entry(byte: u8) void {
77// backend=stage2
88// target=native
99//
10// :2:20: error: @bitCast size mismatch: destination type 'u7' has 7 bits but source type 'u8' has 8 bits
10// :2:22: error: @bitCast size mismatch: destination type 'u7' has 7 bits but source type 'u8' has 8 bits
test/cases/compile_errors/bitCast_with_different_sizes_inside_an_expression.zig+3-2
......@@ -1,5 +1,6 @@
11export fn entry() void {
2 var foo = (@as(u8, @bitCast(@as(f32, 1.0))) == 0xf);
2 const f: f32 = 1.0;
3 const foo = (@as(u8, @bitCast(f)) == 0xf);
34 _ = foo;
45}
56
......@@ -7,4 +8,4 @@ export fn entry() void {
78// backend=stage2
89// target=native
910//
10// :2:24: error: @bitCast size mismatch: destination type 'u8' has 8 bits but source type 'f32' has 32 bits
11// :3:26: error: @bitCast size mismatch: destination type 'u8' has 8 bits but source type 'f32' has 32 bits
test/cases/compile_errors/branch_in_comptime_only_scope_uses_condbr_inline.zig+5-3
......@@ -1,5 +1,6 @@
11pub export fn entry1() void {
22 var x: u32 = 3;
3 _ = &x;
34 _ = @shuffle(u32, [_]u32{0}, @as(@Vector(1, u32), @splat(0)), [_]i8{
45 if (x > 1) 1 else -1,
56 });
......@@ -7,6 +8,7 @@ pub export fn entry1() void {
78
89pub export fn entry2() void {
910 var y: ?i8 = -1;
11 _ = &y;
1012 _ = @shuffle(u32, [_]u32{0}, @as(@Vector(1, u32), @splat(0)), [_]i8{
1113 y orelse 1,
1214 });
......@@ -16,6 +18,6 @@ pub export fn entry2() void {
1618// backend=stage2
1719// target=native
1820//
19// :4:15: error: unable to evaluate comptime expression
20// :4:13: note: operation is runtime due to this operand
21// :11:11: error: unable to evaluate comptime expression
21// :5:15: error: unable to evaluate comptime expression
22// :5:13: note: operation is runtime due to this operand
23// :13:11: error: unable to evaluate comptime expression
test/cases/compile_errors/break_void_result_location.zig+3-2
......@@ -10,6 +10,7 @@ export fn f2() void {
1010}
1111export fn f3() void {
1212 var t: bool = true;
13 _ = &t;
1314 const x: usize = while (t) {
1415 break;
1516 };
......@@ -28,5 +29,5 @@ export fn f4() void {
2829//
2930// :2:22: error: expected type 'usize', found 'void'
3031// :7:9: error: expected type 'usize', found 'void'
31// :14:9: error: expected type 'usize', found 'void'
32// :20:9: error: expected type 'usize', found 'void'
32// :15:9: error: expected type 'usize', found 'void'
33// :21:9: error: expected type 'usize', found 'void'
test/cases/compile_errors/c_pointer_to_void.zig+3-3
......@@ -1,5 +1,5 @@
11export fn entry() void {
2 var a: [*c]void = undefined;
2 const a: [*c]void = undefined;
33 _ = a;
44}
55
......@@ -7,5 +7,5 @@ export fn entry() void {
77// backend=stage2
88// target=native
99//
10// :2:16: error: C pointers cannot point to non-C-ABI-compatible type 'void'
11// :2:16: note: 'void' is a zero bit type; for C 'void' use 'anyopaque'
10// :2:18: error: C pointers cannot point to non-C-ABI-compatible type 'void'
11// :2:18: note: 'void' is a zero bit type; for C 'void' use 'anyopaque'
test/cases/compile_errors/callconv_stdcall_fastcall_thiscall_on_unsupported_platform.zig+3-3
......@@ -2,15 +2,15 @@ const F1 = fn () callconv(.Stdcall) void;
22const F2 = fn () callconv(.Fastcall) void;
33const F3 = fn () callconv(.Thiscall) void;
44export fn entry1() void {
5 var a: F1 = undefined;
5 const a: F1 = undefined;
66 _ = a;
77}
88export fn entry2() void {
9 var a: F2 = undefined;
9 const a: F2 = undefined;
1010 _ = a;
1111}
1212export fn entry3() void {
13 var a: F3 = undefined;
13 const a: F3 = undefined;
1414 _ = a;
1515}
1616
test/cases/compile_errors/cast_between_optional_T_where_T_is_not_a_pointer.zig+5-3
......@@ -4,6 +4,7 @@ export fn entry1() void {
44 var a: fnty1 = undefined;
55 var b: fnty2 = undefined;
66 a = b;
7 _ = &b;
78}
89
910pub const fnty3 = ?*const fn (u63) void;
......@@ -11,6 +12,7 @@ export fn entry2() void {
1112 var a: fnty3 = undefined;
1213 var b: fnty2 = undefined;
1314 a = b;
15 _ = &b;
1416}
1517
1618// error
......@@ -21,6 +23,6 @@ export fn entry2() void {
2123// :6:9: note: pointer type child 'fn (u64) void' cannot cast into pointer type child 'fn (i8) void'
2224// :6:9: note: parameter 0 'u64' cannot cast into 'i8'
2325// :6:9: note: unsigned 64-bit int cannot represent all possible signed 8-bit values
24// :13:9: error: expected type '?*const fn (u63) void', found '?*const fn (u64) void'
25// :13:9: note: pointer type child 'fn (u64) void' cannot cast into pointer type child 'fn (u63) void'
26// :13:9: note: parameter 0 'u64' cannot cast into 'u63'
26// :14:9: error: expected type '?*const fn (u63) void', found '?*const fn (u64) void'
27// :14:9: note: pointer type child 'fn (u64) void' cannot cast into pointer type child 'fn (u63) void'
28// :14:9: note: parameter 0 'u64' cannot cast into 'u63'
test/cases/compile_errors/cast_error_union_of_global_error_set_to_error_union_of_smaller_error_set.zig+3-3
......@@ -1,6 +1,6 @@
11const SmallErrorSet = error{A};
22export fn entry() void {
3 var x: SmallErrorSet!i32 = foo();
3 const x: SmallErrorSet!i32 = foo();
44 _ = x;
55}
66fn foo() anyerror!i32 {
......@@ -11,5 +11,5 @@ fn foo() anyerror!i32 {
1111// backend=stage2
1212// target=native
1313//
14// :3:35: error: expected type 'error{A}!i32', found 'anyerror!i32'
15// :3:35: note: global error set cannot cast into a smaller set
14// :3:37: error: expected type 'error{A}!i32', found 'anyerror!i32'
15// :3:37: note: global error set cannot cast into a smaller set
test/cases/compile_errors/cast_global_error_set_to_error_set.zig+3-3
......@@ -1,6 +1,6 @@
11const SmallErrorSet = error{A};
22export fn entry() void {
3 var x: SmallErrorSet = foo();
3 const x: SmallErrorSet = foo();
44 _ = x;
55}
66fn foo() anyerror {
......@@ -11,5 +11,5 @@ fn foo() anyerror {
1111// backend=stage2
1212// target=native
1313//
14// :3:31: error: expected type 'error{A}', found 'anyerror'
15// :3:31: note: global error set cannot cast into a smaller set
14// :3:33: error: expected type 'error{A}', found 'anyerror'
15// :3:33: note: global error set cannot cast into a smaller set
test/cases/compile_errors/catch_on_undefined_value.zig+1-1
......@@ -1,5 +1,5 @@
11comptime {
2 var a: anyerror!bool = undefined;
2 const a: anyerror!bool = undefined;
33 if (a catch false) {}
44}
55
test/cases/compile_errors/compare_optional_to_non_optional_with_incomparable_type.zig+2-2
......@@ -1,6 +1,6 @@
11export fn entry() void {
2 var x: ?[3]i32 = undefined;
3 var y: [3]i32 = undefined;
2 const x: ?[3]i32 = undefined;
3 const y: [3]i32 = undefined;
44 _ = (x == y);
55}
66
test/cases/compile_errors/comparison_operators_with_undefined_value.zig+6-6
......@@ -1,36 +1,36 @@
11// operator ==
22comptime {
3 var a: i64 = undefined;
3 const a: i64 = undefined;
44 var x: i32 = 0;
55 if (a == a) x += 1;
66}
77// operator !=
88comptime {
9 var a: i64 = undefined;
9 const a: i64 = undefined;
1010 var x: i32 = 0;
1111 if (a != a) x += 1;
1212}
1313// operator >
1414comptime {
15 var a: i64 = undefined;
15 const a: i64 = undefined;
1616 var x: i32 = 0;
1717 if (a > a) x += 1;
1818}
1919// operator <
2020comptime {
21 var a: i64 = undefined;
21 const a: i64 = undefined;
2222 var x: i32 = 0;
2323 if (a < a) x += 1;
2424}
2525// operator >=
2626comptime {
27 var a: i64 = undefined;
27 const a: i64 = undefined;
2828 var x: i32 = 0;
2929 if (a >= a) x += 1;
3030}
3131// operator <=
3232comptime {
33 var a: i64 = undefined;
33 const a: i64 = undefined;
3434 var x: i32 = 0;
3535 if (a <= a) x += 1;
3636}
test/cases/compile_errors/compile_error_in_struct_init_expression.zig+1-1
......@@ -3,7 +3,7 @@ const Foo = struct {
33 b: i32,
44};
55export fn entry() void {
6 var x = Foo{
6 const x: Foo = .{
77 .b = 5,
88 };
99 _ = x;
test/cases/compile_errors/compile_time_null_ptr_cast.zig+1-1
......@@ -1,5 +1,5 @@
11comptime {
2 var opt_ptr: ?*i32 = null;
2 const opt_ptr: ?*i32 = null;
33 const ptr: *i32 = @ptrCast(opt_ptr);
44 _ = ptr;
55}
test/cases/compile_errors/compile_time_undef_ptr_cast.zig+1
......@@ -1,6 +1,7 @@
11comptime {
22 var undef_ptr: *i32 = undefined;
33 const ptr: *i32 = @ptrCast(undef_ptr);
4 _ = &undef_ptr;
45 _ = ptr;
56}
67
test/cases/compile_errors/comptime_cast_enum_to_union_but_field_has_payload.zig+1-1
......@@ -6,7 +6,7 @@ const Value = union(Letter) {
66};
77export fn entry() void {
88 var x: Value = Letter.A;
9 _ = x;
9 _ = &x;
1010}
1111
1212// error
test/cases/compile_errors/comptime_continue_inside_runtime_if_bool.zig+3-2
......@@ -1,5 +1,6 @@
11export fn entry() void {
22 var p: usize = undefined;
3 _ = &p;
34 comptime var q = true;
45 inline while (q) {
56 if (p == 11) continue;
......@@ -11,5 +12,5 @@ export fn entry() void {
1112// backend=stage2
1213// target=native
1314//
14// :5:22: error: comptime control flow inside runtime block
15// :5:15: note: runtime control flow here
15// :6:22: error: comptime control flow inside runtime block
16// :6:15: note: runtime control flow here
test/cases/compile_errors/comptime_continue_inside_runtime_if_error.zig+3-2
......@@ -1,5 +1,6 @@
11export fn entry() void {
22 var p: anyerror!i32 = undefined;
3 _ = &p;
34 comptime var q = true;
45 inline while (q) {
56 if (p) |_| continue else |_| {}
......@@ -11,5 +12,5 @@ export fn entry() void {
1112// backend=stage2
1213// target=native
1314//
14// :5:20: error: comptime control flow inside runtime block
15// :5:13: note: runtime control flow here
15// :6:20: error: comptime control flow inside runtime block
16// :6:13: note: runtime control flow here
test/cases/compile_errors/comptime_continue_inside_runtime_if_optional.zig+3-2
......@@ -1,5 +1,6 @@
11export fn entry() void {
22 var p: ?i32 = undefined;
3 _ = &p;
34 comptime var q = true;
45 inline while (q) {
56 if (p) |_| continue;
......@@ -11,5 +12,5 @@ export fn entry() void {
1112// backend=stage2
1213// target=native
1314//
14// :5:20: error: comptime control flow inside runtime block
15// :5:13: note: runtime control flow here
15// :6:20: error: comptime control flow inside runtime block
16// :6:13: note: runtime control flow here
test/cases/compile_errors/comptime_continue_inside_runtime_switch.zig+3-2
......@@ -1,5 +1,6 @@
11export fn entry() void {
22 var p: i32 = undefined;
3 _ = &p;
34 comptime var q = true;
45 inline while (q) {
56 switch (p) {
......@@ -14,5 +15,5 @@ export fn entry() void {
1415// backend=stage2
1516// target=native
1617//
17// :6:19: error: comptime control flow inside runtime block
18// :5:17: note: runtime control flow here
18// :7:19: error: comptime control flow inside runtime block
19// :6:17: note: runtime control flow here
test/cases/compile_errors/comptime_continue_inside_runtime_while_bool.zig+3-2
......@@ -1,5 +1,6 @@
11export fn entry() void {
22 var p: usize = undefined;
3 _ = &p;
34 comptime var q = true;
45 outer: inline while (q) {
56 while (p == 11) continue :outer;
......@@ -11,5 +12,5 @@ export fn entry() void {
1112// backend=stage2
1213// target=native
1314//
14// :5:25: error: comptime control flow inside runtime block
15// :5:18: note: runtime control flow here
15// :6:25: error: comptime control flow inside runtime block
16// :6:18: note: runtime control flow here
test/cases/compile_errors/comptime_continue_inside_runtime_while_error.zig+3-2
......@@ -1,5 +1,6 @@
11export fn entry() void {
22 var p: anyerror!usize = undefined;
3 _ = &p;
34 comptime var q = true;
45 outer: inline while (q) {
56 while (p) |_| {
......@@ -13,5 +14,5 @@ export fn entry() void {
1314// backend=stage2
1415// target=native
1516//
16// :6:13: error: comptime control flow inside runtime block
17// :5:16: note: runtime control flow here
17// :7:13: error: comptime control flow inside runtime block
18// :6:16: note: runtime control flow here
test/cases/compile_errors/comptime_continue_inside_runtime_while_optional.zig+3-2
......@@ -1,5 +1,6 @@
11export fn entry() void {
22 var p: ?usize = undefined;
3 _ = &p;
34 comptime var q = true;
45 outer: inline while (q) {
56 while (p) |_| continue :outer;
......@@ -11,5 +12,5 @@ export fn entry() void {
1112// backend=stage2
1213// target=native
1314//
14// :5:23: error: comptime control flow inside runtime block
15// :5:16: note: runtime control flow here
15// :6:23: error: comptime control flow inside runtime block
16// :6:16: note: runtime control flow here
test/cases/compile_errors/comptime_continue_to_outer_inline_loop.zig+3-2
......@@ -1,5 +1,6 @@
11pub export fn entry() void {
22 var a = false;
3 _ = &a;
34 const arr1 = .{ 1, 2, 3 };
45 loop: inline for (arr1) |val1| {
56 _ = val1;
......@@ -17,5 +18,5 @@ pub export fn entry() void {
1718// backend=stage2
1819// target=native
1920//
20// :9:30: error: comptime control flow inside runtime block
21// :6:13: note: runtime control flow here
21// :10:30: error: comptime control flow inside runtime block
22// :7:13: note: runtime control flow here
test/cases/compile_errors/comptime_if_inside_runtime_for.zig+4-3
......@@ -1,8 +1,9 @@
11export fn entry() void {
22 var x: u32 = 0;
3 _ = &x;
34 for (0..1, 1..2) |_, _| {
45 var y = x + if (x == 0) 1 else 0;
5 _ = y;
6 _ = &y;
67 }
78}
89
......@@ -10,5 +11,5 @@ export fn entry() void {
1011// backend=stage2
1112// target=native
1213//
13// :4:21: error: value with comptime-only type 'comptime_int' depends on runtime control flow
14// :3:10: note: runtime control flow here
14// :5:21: error: value with comptime-only type 'comptime_int' depends on runtime control flow
15// :4:10: note: runtime control flow here
test/cases/compile_errors/comptime_slice_of_an_undefined_slice.zig+1-1
......@@ -1,7 +1,7 @@
11comptime {
22 var a: []u8 = undefined;
33 var b = a[0..10];
4 _ = b;
4 _ = &b;
55}
66
77// error
test/cases/compile_errors/comptime_struct_field_no_init_value.zig+1-1
......@@ -3,7 +3,7 @@ const Foo = struct {
33};
44export fn entry() void {
55 var f: Foo = undefined;
6 _ = f;
6 _ = &f;
77}
88
99// error
test/cases/compile_errors/comptime_vector_overflow_shows_the_index.zig+1-1
......@@ -2,7 +2,7 @@ comptime {
22 var a: @Vector(4, u8) = [_]u8{ 1, 2, 255, 4 };
33 var b: @Vector(4, u8) = [_]u8{ 5, 6, 1, 8 };
44 var x = a + b;
5 _ = x;
5 _ = .{ &a, &b, &x };
66}
77
88// error
test/cases/compile_errors/constant_inside_comptime_function_has_compile_error.zig+2-4
......@@ -1,9 +1,7 @@
11const ContextAllocator = MemoryPool(usize);
22
33pub fn MemoryPool(comptime T: type) type {
4 const free_list_t = @compileError(
5 "aoeu",
6 );
4 const free_list_t = @compileError("aoeu");
75 _ = T;
86
97 return struct {
......@@ -12,7 +10,7 @@ pub fn MemoryPool(comptime T: type) type {
1210}
1311
1412export fn entry() void {
15 var allocator: ContextAllocator = undefined;
13 const allocator: ContextAllocator = undefined;
1614 _ = allocator;
1715}
1816
test/cases/compile_errors/deref_on_undefined_value.zig+1-1
......@@ -1,5 +1,5 @@
11comptime {
2 var a: *u8 = undefined;
2 const a: *u8 = undefined;
33 _ = a.*;
44}
55
test/cases/compile_errors/deref_slice_and_get_len_field.zig+1
......@@ -1,6 +1,7 @@
11export fn entry() void {
22 var a: []u8 = undefined;
33 _ = a.*.len;
4 _ = &a;
45}
56
67// error
test/cases/compile_errors/dereference_an_array.zig+2-1
......@@ -1,6 +1,7 @@
11var s_buffer: [10]u8 = undefined;
22pub fn pass(in: []u8) []u8 {
33 var out = &s_buffer;
4 _ = &out;
45 out.*.* = in[0];
56 return out.*[0..1];
67}
......@@ -13,4 +14,4 @@ export fn entry() usize {
1314// backend=stage2
1415// target=native
1516//
16// :4:10: error: cannot dereference non-pointer type '[10]u8'
17// :5:10: error: cannot dereference non-pointer type '[10]u8'
test/cases/compile_errors/dereferencing_invalid_payload_ptr_at_comptime.zig+1-1
......@@ -16,7 +16,7 @@ comptime {
1616 _ = payload_ptr.*;
1717}
1818comptime {
19 var val: u8 = 15;
19 const val: u8 = 15;
2020 var err_union: anyerror!u8 = val;
2121
2222 const payload_ptr = &(err_union catch unreachable);
test/cases/compile_errors/directly_embedding_opaque_type_in_struct_and_union.zig+2-2
......@@ -8,11 +8,11 @@ const Bar = union {
88};
99export fn a() void {
1010 var foo: Foo = undefined;
11 _ = foo;
11 _ = &foo;
1212}
1313export fn b() void {
1414 var bar: Bar = undefined;
15 _ = bar;
15 _ = &bar;
1616}
1717export fn c() void {
1818 const baz = &@as(O, undefined);
test/cases/compile_errors/div_on_undefined_value.zig+1
......@@ -1,6 +1,7 @@
11comptime {
22 var a: i64 = undefined;
33 _ = a / a;
4 _ = &a;
45}
56
67// error
test/cases/compile_errors/double_pointer_to_anyopaque_pointer.zig+4-3
......@@ -11,12 +11,13 @@ pub export fn entry2() void {
1111fn func(_: ?*anyopaque) void {}
1212pub export fn entry3() void {
1313 var x: *?*usize = undefined;
14
14 _ = &x;
1515 const ptr: *const anyopaque = x;
1616 _ = ptr;
1717}
1818export fn entry4() void {
1919 var a: []*u32 = undefined;
20 _ = &a;
2021 var b: []anyopaque = undefined;
2122 b = a;
2223}
......@@ -32,5 +33,5 @@ export fn entry4() void {
3233// :11:12: note: parameter type declared here
3334// :15:35: error: expected type '*const anyopaque', found '*?*usize'
3435// :15:35: note: cannot implicitly cast double pointer '*?*usize' to anyopaque pointer '*const anyopaque'
35// :21:9: error: expected type '[]anyopaque', found '[]*u32'
36// :21:9: note: cannot implicitly cast double pointer '[]*u32' to anyopaque pointer '[]anyopaque'
36// :22:9: error: expected type '[]anyopaque', found '[]*u32'
37// :22:9: note: cannot implicitly cast double pointer '[]*u32' to anyopaque pointer '[]anyopaque'
test/cases/compile_errors/empty_switch_on_an_integer.zig+1-1
......@@ -1,5 +1,5 @@
11export fn entry() void {
2 var x: u32 = 0;
2 const x: u32 = 0;
33 switch (x) {}
44}
55
test/cases/compile_errors/enum_backed_by_comptime_int_must_be_comptime.zig+1-1
......@@ -1,7 +1,7 @@
11pub export fn entry() void {
22 const E = enum(comptime_int) { a, b, c, _ };
33 var e: E = .a;
4 _ = e;
4 _ = &e;
55}
66
77// error
test/cases/compile_errors/enum_field_value_references_enum.zig+1-1
......@@ -3,7 +3,7 @@ pub const Foo = enum(c_int) {
33 C = D,
44};
55export fn entry() void {
6 var s: Foo = Foo.E;
6 const s: Foo = Foo.E;
77 _ = s;
88}
99const D = 1;
test/cases/compile_errors/enum_in_field_count_range_but_not_matching_tag.zig+2-2
......@@ -3,7 +3,7 @@ const Foo = enum(u32) {
33 B = 11,
44};
55export fn entry() void {
6 var x: Foo = @enumFromInt(0);
6 const x: Foo = @enumFromInt(0);
77 _ = x;
88}
99
......@@ -11,5 +11,5 @@ export fn entry() void {
1111// backend=stage2
1212// target=native
1313//
14// :6:18: error: enum 'tmp.Foo' has no tag with value '0'
14// :6:20: error: enum 'tmp.Foo' has no tag with value '0'
1515// :1:13: note: enum declared here
test/cases/compile_errors/enum_value_already_taken.zig+1-1
......@@ -6,7 +6,7 @@ const MultipleChoice = enum(u32) {
66 E = 60,
77};
88export fn entry() void {
9 var x = MultipleChoice.C;
9 const x = MultipleChoice.C;
1010 _ = x;
1111}
1212
test/cases/compile_errors/error_in_struct_initializer_doesnt_crash_the_compiler.zig+1-1
......@@ -4,7 +4,7 @@ pub export fn entry() void {
44 e: u8,
55 };
66 var a = .{@sizeOf(bitfield)};
7 _ = a;
7 _ = &a;
88}
99
1010// error
test/cases/compile_errors/error_union_operator_with_non_error_set_LHS.zig+1-1
......@@ -1,6 +1,6 @@
11comptime {
22 const z = i32!i32;
3 var x: z = undefined;
3 const x: z = undefined;
44 _ = x;
55}
66
test/cases/compile_errors/error_when_evaluating_return_type.zig+1-1
......@@ -6,7 +6,7 @@ const Foo = struct {
66 }
77};
88export fn entry() void {
9 var rule_set = try Foo.init();
9 const rule_set = try Foo.init();
1010 _ = rule_set;
1111}
1212
test/cases/compile_errors/explain_why_generic_fn_is_called_at_comptime.zig+3-2
......@@ -11,12 +11,13 @@ fn foo(a: u8, comptime PtrTy: type) S(PtrTy) {
1111}
1212pub export fn entry() void {
1313 var a: u8 = 1;
14 _ = &a;
1415 _ = foo(a, fn () void);
1516}
1617// error
1718// backend=stage2
1819// target=native
1920//
20// :14:13: error: unable to resolve comptime value
21// :14:13: note: argument to function being called at comptime must be comptime-known
21// :15:13: error: unable to resolve comptime value
22// :15:13: note: argument to function being called at comptime must be comptime-known
2223// :9:38: note: expression is evaluated at comptime because the generic function was instantiated with a comptime-only return type
test/cases/compile_errors/explicit_error_set_cast_known_at_comptime_violates_error_sets.zig+3-3
......@@ -1,8 +1,8 @@
11const Set1 = error{ A, B };
22const Set2 = error{ A, C };
33comptime {
4 var x = Set1.B;
5 var y: Set2 = @errorCast(x);
4 const x = Set1.B;
5 const y: Set2 = @errorCast(x);
66 _ = y;
77}
88
......@@ -10,4 +10,4 @@ comptime {
1010// backend=stage2
1111// target=native
1212//
13// :5:19: error: 'error.B' not a member of error set 'error{C,A}'
13// :5:21: error: 'error.B' not a member of error set 'error{C,A}'
test/cases/compile_errors/explicitly_casting_non_tag_type_to_enum.zig+2-2
......@@ -7,7 +7,7 @@ const Small = enum(u2) {
77
88export fn entry() void {
99 var y = @as(f32, 3);
10 var x: Small = @enumFromInt(y);
10 const x: Small = @enumFromInt((&y).*);
1111 _ = x;
1212}
1313
......@@ -15,4 +15,4 @@ export fn entry() void {
1515// backend=stage2
1616// target=native
1717//
18// :10:33: error: expected integer type, found 'f32'
18// :10:39: error: expected integer type, found 'f32'
test/cases/compile_errors/extern_union_field_missing_type.zig+1-1
......@@ -2,7 +2,7 @@ const Letter = extern union {
22 A,
33};
44export fn entry() void {
5 var a = Letter{ .A = {} };
5 const a: Letter = .{ .A = {} };
66 _ = a;
77}
88
test/cases/compile_errors/extern_union_given_enum_tag_type.zig+1-1
......@@ -9,7 +9,7 @@ const Payload = extern union(Letter) {
99 C: bool,
1010};
1111export fn entry() void {
12 var a = Payload{ .A = 1234 };
12 const a: Payload = .{ .A = 1234 };
1313 _ = a;
1414}
1515
test/cases/compile_errors/field_access_of_slices.zig+3-2
......@@ -1,5 +1,6 @@
11export fn entry() void {
22 var slice: []i32 = undefined;
3 _ = &slice;
34 const info = @TypeOf(slice).unknown;
45 _ = info;
56}
......@@ -8,5 +9,5 @@ export fn entry() void {
89// backend=stage2
910// target=native
1011//
11// :3:32: error: type '[]i32' has no members
12// :3:32: note: slice values have 'len' and 'ptr' members
12// :4:32: error: type '[]i32' has no members
13// :4:32: note: slice values have 'len' and 'ptr' members
test/cases/compile_errors/for.zig+4-3
......@@ -17,6 +17,7 @@ export fn c() void {
1717 for (buf) |*byte| {
1818 _ = byte;
1919 }
20 _ = &buf;
2021}
2122export fn d() void {
2223 const x: [*]const u8 = "hello";
......@@ -39,6 +40,6 @@ export fn d() void {
3940// :10:14: note: for loop operand must be a range, array, slice, tuple, or vector
4041// :17:16: error: pointer capture of non pointer type '[10]u8'
4142// :17:10: note: consider using '&' here
42// :24:5: error: unbounded for loop
43// :24:10: note: type '[*]const u8' has no upper bound
44// :24:18: note: type '[*]const u8' has no upper bound
43// :25:5: error: unbounded for loop
44// :25:10: note: type '[*]const u8' has no upper bound
45// :25:18: note: type '[*]const u8' has no upper bound
test/cases/compile_errors/for_loop_body_expression_ignored.zig+1-1
......@@ -7,7 +7,7 @@ export fn f1() void {
77export fn f2() void {
88 var x: anyerror!i32 = error.Bad;
99 for ("hello") |_| returns() else unreachable;
10 _ = x;
10 _ = &x;
1111}
1212export fn f3() void {
1313 for ("hello") |_| {} else true;
test/cases/compile_errors/function_ptr_alignment.zig+5-5
......@@ -1,24 +1,24 @@
11comptime {
22 var a: *align(2) @TypeOf(foo) = undefined;
3 _ = a;
3 _ = &a;
44}
55fn foo() void {}
66
77comptime {
88 var a: *align(1) fn () void = undefined;
9 _ = a;
9 _ = &a;
1010}
1111comptime {
1212 var a: *align(2) fn () align(2) void = undefined;
13 _ = a;
13 _ = &a;
1414}
1515comptime {
1616 var a: *align(2) fn () void = undefined;
17 _ = a;
17 _ = &a;
1818}
1919comptime {
2020 var a: *align(1) fn () align(2) void = undefined;
21 _ = a;
21 _ = &a;
2222}
2323
2424// error
test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig+2-1
......@@ -3,6 +3,7 @@ const std = @import("std");
33pub export fn entry() void {
44 var ohnoes: *usize = undefined;
55 _ = sliceAsBytes(ohnoes);
6 _ = &ohnoes;
67}
78fn sliceAsBytes(slice: anytype) std.meta.trait.isPtrTo(.Array)(@TypeOf(slice)) {}
89
......@@ -10,4 +11,4 @@ fn sliceAsBytes(slice: anytype) std.meta.trait.isPtrTo(.Array)(@TypeOf(slice)) {
1011// backend=llvm
1112// target=native
1213//
13// :7:63: error: expected type 'type', found 'bool'
14// :8:63: error: expected type 'type', found 'bool'
test/cases/compile_errors/generic_method_call_with_invalid_param.zig+5-4
......@@ -11,6 +11,7 @@ export fn callVoidMethodWithBool() void {
1111export fn callComptimeBoolMethodWithRuntimeBool() void {
1212 const s = S{};
1313 var arg = true;
14 _ = &arg;
1415 s.comptimeBoolMethod(arg);
1516}
1617
......@@ -25,8 +26,8 @@ const S = struct {
2526// target=native
2627//
2728// :3:18: error: expected type 'bool', found 'void'
28// :18:43: note: parameter type declared here
29// :8:18: error: expected type 'void', found 'bool'
3029// :19:43: note: parameter type declared here
31// :14:26: error: runtime-known argument passed to comptime parameter
32// :20:57: note: declared comptime here
30// :8:18: error: expected type 'void', found 'bool'
31// :20:43: note: parameter type declared here
32// :15:26: error: runtime-known argument passed to comptime parameter
33// :21:57: note: declared comptime here
test/cases/compile_errors/ignored_expression_in_while_continuation.zig+6-4
......@@ -3,10 +3,12 @@ export fn a() void {
33}
44export fn b() void {
55 var x: anyerror!i32 = 1234;
6 _ = &x;
67 while (x) |_| : (bad()) {} else |_| {}
78}
89export fn c() void {
910 var x: ?i32 = 1234;
11 _ = &x;
1012 while (x) |_| : (bad()) {}
1113}
1214fn bad() anyerror!void {
......@@ -19,7 +21,7 @@ fn bad() anyerror!void {
1921//
2022// :2:24: error: error is ignored
2123// :2:24: note: consider using 'try', 'catch', or 'if'
22// :6:25: error: error is ignored
23// :6:25: note: consider using 'try', 'catch', or 'if'
24// :10:25: error: error is ignored
25// :10:25: note: consider using 'try', 'catch', or 'if'
24// :7:25: error: error is ignored
25// :7:25: note: consider using 'try', 'catch', or 'if'
26// :12:25: error: error is ignored
27// :12:25: note: consider using 'try', 'catch', or 'if'
test/cases/compile_errors/implicit_cast_between_C_pointer_and_Zig_pointer-bad_const-align-child.zig+6-6
......@@ -1,32 +1,32 @@
11export fn a() void {
22 var x: [*c]u8 = undefined;
33 var y: *align(4) u8 = x;
4 _ = y;
4 _ = .{ &x, &y };
55}
66export fn b() void {
77 var x: [*c]const u8 = undefined;
88 var y: *u8 = x;
9 _ = y;
9 _ = .{ &x, &y };
1010}
1111export fn c() void {
1212 var x: [*c]u8 = undefined;
1313 var y: *u32 = x;
14 _ = y;
14 _ = .{ &x, &y };
1515}
1616export fn d() void {
1717 var y: *align(1) u32 = undefined;
1818 var x: [*c]u32 = y;
19 _ = x;
19 _ = .{ &x, &y };
2020}
2121export fn e() void {
2222 var y: *const u8 = undefined;
2323 var x: [*c]u8 = y;
24 _ = x;
24 _ = .{ &x, &y };
2525}
2626export fn f() void {
2727 var y: *u8 = undefined;
2828 var x: [*c]u32 = y;
29 _ = x;
29 _ = .{ &x, &y };
3030}
3131
3232// error
test/cases/compile_errors/implicit_cast_from_f64_to_f32.zig+1-1
......@@ -7,7 +7,7 @@ export fn entry() void {
77export fn entry2() void {
88 var x1: f64 = 1.0;
99 var y2: f32 = x1;
10 _ = y2;
10 _ = .{ &x1, &y2 };
1111}
1212
1313// error
test/cases/compile_errors/implicit_cast_of_error_set_not_a_subset.zig+3-3
......@@ -4,7 +4,7 @@ export fn entry() void {
44 foo(Set1.B);
55}
66fn foo(set1: Set1) void {
7 var x: Set2 = set1;
7 const x: Set2 = set1;
88 _ = x;
99}
1010
......@@ -12,5 +12,5 @@ fn foo(set1: Set1) void {
1212// backend=stage2
1313// target=native
1414//
15// :7:19: error: expected type 'error{C,A}', found 'error{A,B}'
16// :7:19: note: 'error.B' not a member of destination error set
15// :7:21: error: expected type 'error{C,A}', found 'error{A,B}'
16// :7:21: note: 'error.B' not a member of destination error set
test/cases/compile_errors/implicit_casting_C_pointers_which_would_mess_up_null_semantics.zig+9-4
......@@ -4,6 +4,9 @@ export fn entry() void {
44 var ptr_opt_many_ptr = &opt_many_ptr;
55 var c_ptr: [*c]const [*c]const u8 = ptr_opt_many_ptr;
66 ptr_opt_many_ptr = c_ptr;
7 _ = &slice;
8 _ = &ptr_opt_many_ptr;
9 _ = &c_ptr;
710}
811export fn entry2() void {
912 var buf: [4]u8 = "aoeu".*;
......@@ -11,7 +14,9 @@ export fn entry2() void {
1114 var opt_many_ptr: [*]u8 = slice.ptr;
1215 var ptr_opt_many_ptr = &opt_many_ptr;
1316 var c_ptr: [*c][*c]const u8 = ptr_opt_many_ptr;
14 _ = c_ptr;
17 _ = &slice;
18 _ = &ptr_opt_many_ptr;
19 _ = &c_ptr;
1520}
1621
1722// error
......@@ -21,6 +26,6 @@ export fn entry2() void {
2126// :6:24: error: expected type '*const [*]const u8', found '[*c]const [*c]const u8'
2227// :6:24: note: pointer type child '[*c]const u8' cannot cast into pointer type child '[*]const u8'
2328// :6:24: note: '[*c]const u8' could have null values which are illegal in type '[*]const u8'
24// :13:35: error: expected type '[*c][*c]const u8', found '*[*]u8'
25// :13:35: note: pointer type child '[*]u8' cannot cast into pointer type child '[*c]const u8'
26// :13:35: note: mutable '[*]u8' allows illegal null values stored to type '[*c]const u8'
29// :16:35: error: expected type '[*c][*c]const u8', found '*[*]u8'
30// :16:35: note: pointer type child '[*]u8' cannot cast into pointer type child '[*c]const u8'
31// :16:35: note: mutable '[*]u8' allows illegal null values stored to type '[*c]const u8'
test/cases/compile_errors/implicit_casting_null_c_pointer_to_zig_pointer.zig+3-2
......@@ -1,6 +1,7 @@
11comptime {
22 var c_ptr: [*c]u8 = 0;
3 var zig_ptr: *u8 = c_ptr;
3 const zig_ptr: *u8 = c_ptr;
4 _ = &c_ptr;
45 _ = zig_ptr;
56}
67
......@@ -8,4 +9,4 @@ comptime {
89// backend=stage2
910// target=native
1011//
11// :3:24: error: null pointer casted to type '*u8'
12// :3:26: error: null pointer casted to type '*u8'
test/cases/compile_errors/implicitly_casting_enum_to_tag_type.zig+1-1
......@@ -7,7 +7,7 @@ const Small = enum(u2) {
77
88export fn entry() void {
99 var x: u2 = Small.Two;
10 _ = x;
10 _ = &x;
1111}
1212
1313// error
test/cases/compile_errors/incompatible sub-byte fields.zig +4-3
......@@ -11,6 +11,7 @@ export fn entry() void {
1111 var a = A{ .a = 2, .b = 2 };
1212 var b = B{ .q = 22, .a = 3, .b = 2 };
1313 var t: usize = 0;
14 _ = &t;
1415 const ptr = switch (t) {
1516 0 => &a.a,
1617 1 => &b.a,
......@@ -24,6 +25,6 @@ export fn entry() void {
2425// backend=stage2
2526// target=native
2627//
27// :14:17: error: incompatible types: '*align(1:0:1) u2' and '*align(2:8:2) u2'
28// :15:14: note: type '*align(1:0:1) u2' here
29// :16:14: note: type '*align(2:8:2) u2' here
28// :15:17: error: incompatible types: '*align(1:0:1) u2' and '*align(2:8:2) u2'
29// :16:14: note: type '*align(1:0:1) u2' here
30// :17:14: note: type '*align(2:8:2) u2' here
test/cases/compile_errors/incompatible_sentinels.zig+2-2
......@@ -8,11 +8,11 @@ export fn entry2(ptr: [*]u8) [*:0]u8 {
88}
99export fn entry3() void {
1010 var array: [2:0]u8 = [_:255]u8{ 1, 2 };
11 _ = array;
11 _ = &array;
1212}
1313export fn entry4() void {
1414 var array: [2:0]u8 = [_]u8{ 1, 2 };
15 _ = array;
15 _ = &array;
1616}
1717
1818// error
test/cases/compile_errors/incorrect_pointer_dereference_syntax.zig+1
......@@ -1,6 +1,7 @@
11pub export fn entry() void {
22 var a: *u32 = undefined;
33 _ = *a;
4 _ = &a;
45}
56
67// error
test/cases/compile_errors/incorrect_type_to_memset_memcpy.zig+4-4
......@@ -1,17 +1,17 @@
11pub export fn entry() void {
22 var buf: [5]u8 = .{ 1, 2, 3, 4, 5 };
3 var slice: []u8 = &buf;
3 const slice: []u8 = &buf;
44 const a: u32 = 1234;
55 @memcpy(slice.ptr, @as([*]const u8, @ptrCast(&a)));
66}
77pub export fn entry1() void {
88 var buf: [5]u8 = .{ 1, 2, 3, 4, 5 };
9 var ptr: *u8 = &buf[0];
9 const ptr: *u8 = &buf[0];
1010 @memcpy(ptr, 0);
1111}
1212pub export fn entry2() void {
1313 var buf: [5]u8 = .{ 1, 2, 3, 4, 5 };
14 var ptr: *u8 = &buf[0];
14 const ptr: *u8 = &buf[0];
1515 @memset(ptr, 0);
1616}
1717pub export fn non_matching_lengths() void {
......@@ -29,7 +29,7 @@ pub export fn memcpy_const_dest_ptr() void {
2929 @memcpy(&buf1, &buf2);
3030}
3131pub export fn memset_array() void {
32 var buf: [5]u8 = .{ 1, 2, 3, 4, 5 };
32 const buf: [5]u8 = .{ 1, 2, 3, 4, 5 };
3333 @memcpy(buf, 1);
3434}
3535
test/cases/compile_errors/indexing_an_array_of_size_zero_with_runtime_index.zig+2-1
......@@ -1,6 +1,7 @@
11const array = [_]u8{};
22export fn foo() void {
33 var index: usize = 0;
4 _ = &index;
45 const pointer = &array[index];
56 _ = pointer;
67}
......@@ -9,4 +10,4 @@ export fn foo() void {
910// backend=stage2
1011// target=native
1112//
12// :4:27: error: indexing into empty array is not allowed
13// :5:27: error: indexing into empty array is not allowed
test/cases/compile_errors/inline_call_runtime_value_to_comptime_param.zig+1-1
......@@ -6,7 +6,7 @@ fn acceptRuntime(value: u64) void {
66}
77pub export fn entry() void {
88 var value: u64 = 0;
9 acceptRuntime(value);
9 acceptRuntime((&value).*);
1010}
1111
1212// error
test/cases/compile_errors/int-float_conversion_to_comptime_int-float.zig+6-4
......@@ -1,9 +1,11 @@
11export fn foo() void {
22 var a: f32 = 2;
3 _ = &a;
34 _ = @as(comptime_int, @intFromFloat(a));
45}
56export fn bar() void {
67 var a: u32 = 2;
8 _ = &a;
79 _ = @as(comptime_float, @floatFromInt(a));
810}
911
......@@ -11,7 +13,7 @@ export fn bar() void {
1113// backend=stage2
1214// target=native
1315//
14// :3:41: error: unable to resolve comptime value
15// :3:41: note: value being casted to 'comptime_int' must be comptime-known
16// :7:43: error: unable to resolve comptime value
17// :7:43: note: value being casted to 'comptime_float' must be comptime-known
16// :4:41: error: unable to resolve comptime value
17// :4:41: note: value being casted to 'comptime_int' must be comptime-known
18// :9:43: error: unable to resolve comptime value
19// :9:43: note: value being casted to 'comptime_float' must be comptime-known
test/cases/compile_errors/intFromPtr_0_to_non_optional_pointer.zig+2-2
......@@ -1,5 +1,5 @@
11export fn entry() void {
2 var b: *i32 = @ptrFromInt(0);
2 const b: *i32 = @ptrFromInt(0);
33 _ = b;
44}
55
......@@ -7,4 +7,4 @@ export fn entry() void {
77// backend=stage2
88// target=native
99//
10// :2:31: error: pointer type '*i32' does not allow address zero
10// :2:33: error: pointer type '*i32' does not allow address zero
test/cases/compile_errors/int_to_err_global_invalid_number.zig+1-1
......@@ -5,7 +5,7 @@ const Set1 = error{
55comptime {
66 var x: u16 = 3;
77 var y = @errorFromInt(x);
8 _ = y;
8 _ = .{ &x, &y };
99}
1010
1111// error
test/cases/compile_errors/int_to_err_non_global_invalid_number.zig+3-3
......@@ -7,8 +7,8 @@ const Set2 = error{
77 C,
88};
99comptime {
10 var x = @intFromError(Set1.B);
11 var y: Set2 = @errorCast(@errorFromInt(x));
10 const x = @intFromError(Set1.B);
11 const y: Set2 = @errorCast(@errorFromInt(x));
1212 _ = y;
1313}
1414
......@@ -16,4 +16,4 @@ comptime {
1616// backend=llvm
1717// target=native
1818//
19// :11:19: error: 'error.B' not a member of error set 'error{C,A}'
19// :11:21: error: 'error.B' not a member of error set 'error{C,A}'
test/cases/compile_errors/integer_cast_truncates_bits.zig+2-2
......@@ -11,12 +11,12 @@ export fn entry2() void {
1111export fn entry3() void {
1212 var spartan_count: u16 = 300;
1313 var byte: u8 = spartan_count;
14 _ = byte;
14 _ = .{ &spartan_count, &byte };
1515}
1616export fn entry4() void {
1717 var signed: i8 = -1;
1818 var unsigned: u64 = signed;
19 _ = unsigned;
19 _ = .{ &signed, &unsigned };
2020}
2121
2222// error
test/cases/compile_errors/invalid_compare_string.zig+4-4
......@@ -1,20 +1,20 @@
11comptime {
2 var a = "foo";
2 const a = "foo";
33 if (a == "foo") unreachable;
44}
55comptime {
6 var a = "foo";
6 const a = "foo";
77 if (a == ("foo")) unreachable; // intentionally allow
88}
99comptime {
10 var a = "foo";
10 const a = "foo";
1111 switch (a) {
1212 "foo" => unreachable,
1313 else => {},
1414 }
1515}
1616comptime {
17 var a = "foo";
17 const a = "foo";
1818 switch (a) {
1919 ("foo") => unreachable, // intentionally allow
2020 else => {},
test/cases/compile_errors/invalid_deref_on_switch_target.zig+1-1
......@@ -1,5 +1,5 @@
11comptime {
2 var tile = Tile.Empty;
2 const tile = Tile.Empty;
33 switch (tile.*) {
44 Tile.Empty => {},
55 Tile.Filled => {},
test/cases/compile_errors/invalid_float_casts.zig+8-4
......@@ -1,17 +1,21 @@
11export fn foo() void {
22 var a: f32 = 2;
3 _ = &a;
34 _ = @as(comptime_float, @floatCast(a));
45}
56export fn bar() void {
67 var a: f32 = 2;
8 _ = &a;
79 _ = @as(f32, @intFromFloat(a));
810}
911export fn baz() void {
1012 var a: f32 = 2;
13 _ = &a;
1114 _ = @as(f32, @floatFromInt(a));
1215}
1316export fn qux() void {
1417 var a: u32 = 2;
18 _ = &a;
1519 _ = @as(f32, @floatCast(a));
1620}
1721
......@@ -19,7 +23,7 @@ export fn qux() void {
1923// backend=stage2
2024// target=native
2125//
22// :3:40: error: unable to cast runtime value to 'comptime_float'
23// :7:18: error: expected integer type, found 'f32'
24// :11:32: error: expected integer type, found 'f32'
25// :15:29: error: expected float or vector type, found 'u32'
26// :4:40: error: unable to cast runtime value to 'comptime_float'
27// :9:18: error: expected integer type, found 'f32'
28// :14:32: error: expected integer type, found 'f32'
29// :19:29: error: expected float or vector type, found 'u32'
test/cases/compile_errors/invalid_inline_else_type.zig+6-3
......@@ -1,5 +1,6 @@
11pub export fn entry1() void {
22 var a: anyerror = undefined;
3 _ = &a;
34 switch (a) {
45 inline else => {},
56 }
......@@ -7,12 +8,14 @@ pub export fn entry1() void {
78const E = enum(u8) { a, _ };
89pub export fn entry2() void {
910 var a: E = undefined;
11 _ = &a;
1012 switch (a) {
1113 inline else => {},
1214 }
1315}
1416pub export fn entry3() void {
1517 var a: *u32 = undefined;
18 _ = &a;
1619 switch (a) {
1720 inline else => {},
1821 }
......@@ -22,6 +25,6 @@ pub export fn entry3() void {
2225// backend=stage2
2326// target=native
2427//
25// :4:21: error: cannot enumerate values of type 'anyerror' for 'inline else'
26// :11:21: error: cannot enumerate values of type 'tmp.E' for 'inline else'
27// :17:21: error: cannot enumerate values of type '*u32' for 'inline else'
28// :5:21: error: cannot enumerate values of type 'anyerror' for 'inline else'
29// :13:21: error: cannot enumerate values of type 'tmp.E' for 'inline else'
30// :20:21: error: cannot enumerate values of type '*u32' for 'inline else'
test/cases/compile_errors/invalid_int_casts.zig+8-4
......@@ -1,17 +1,21 @@
11export fn foo() void {
22 var a: u32 = 2;
3 _ = &a;
34 _ = @as(comptime_int, @intCast(a));
45}
56export fn bar() void {
67 var a: u32 = 2;
8 _ = &a;
79 _ = @as(u32, @floatFromInt(a));
810}
911export fn baz() void {
1012 var a: u32 = 2;
13 _ = &a;
1114 _ = @as(u32, @intFromFloat(a));
1215}
1316export fn qux() void {
1417 var a: f32 = 2;
18 _ = &a;
1519 _ = @as(u32, @intCast(a));
1620}
1721
......@@ -19,7 +23,7 @@ export fn qux() void {
1923// backend=stage2
2024// target=native
2125//
22// :3:36: error: unable to cast runtime value to 'comptime_int'
23// :7:18: error: expected float type, found 'u32'
24// :11:32: error: expected float type, found 'u32'
25// :15:27: error: expected integer or vector, found 'f32'
26// :4:36: error: unable to cast runtime value to 'comptime_int'
27// :9:18: error: expected float type, found 'u32'
28// :14:32: error: expected float type, found 'u32'
29// :19:27: error: expected integer or vector, found 'f32'
test/cases/compile_errors/invalid_multiple_dereferences.zig+5-4
......@@ -1,11 +1,12 @@
11export fn a() void {
22 var box = Box{ .field = 0 };
3 _ = &box;
34 box.*.field = 1;
45}
56export fn b() void {
67 var box = Box{ .field = 0 };
7 var boxPtr = &box;
8 boxPtr.*.*.field = 1;
8 const box_ptr = &box;
9 box_ptr.*.*.field = 1;
910}
1011pub const Box = struct {
1112 field: i32,
......@@ -15,5 +16,5 @@ pub const Box = struct {
1516// backend=stage2
1617// target=native
1718//
18// :3:8: error: cannot dereference non-pointer type 'tmp.Box'
19// :8:13: error: cannot dereference non-pointer type 'tmp.Box'
19// :4:8: error: cannot dereference non-pointer type 'tmp.Box'
20// :9:14: error: cannot dereference non-pointer type 'tmp.Box'
test/cases/compile_errors/invalid_non-exhaustive_enum_to_union.zig+2-2
......@@ -10,12 +10,12 @@ const U = union(E) {
1010export fn foo() void {
1111 var e: E = @enumFromInt(15);
1212 var u: U = e;
13 _ = u;
13 _ = .{ &e, &u };
1414}
1515export fn bar() void {
1616 const e: E = @enumFromInt(15);
1717 var u: U = e;
18 _ = u;
18 _ = &u;
1919}
2020
2121// error
test/cases/compile_errors/invalid_peer_type_resolution.zig+20-18
......@@ -1,11 +1,13 @@
11export fn optionalVector() void {
22 var x: ?@Vector(10, i32) = undefined;
33 var y: @Vector(11, i32) = undefined;
4 _ = .{ &x, &y };
45 _ = @TypeOf(x, y);
56}
67export fn badTupleField() void {
78 var x = .{ @as(u8, 0), @as(u32, 1) };
89 var y = .{ @as(u8, 1), "hello" };
10 _ = .{ &x, &y };
911 _ = @TypeOf(x, y);
1012}
1113export fn badNestedField() void {
......@@ -30,21 +32,21 @@ export fn incompatiblePointers4() void {
3032// backend=llvm
3133// target=native
3234//
33// :4:9: error: incompatible types: '?@Vector(10, i32)' and '@Vector(11, i32)'
34// :4:17: note: type '?@Vector(10, i32)' here
35// :4:20: note: type '@Vector(11, i32)' here
36// :9:9: error: struct field '1' has conflicting types
37// :9:9: note: incompatible types: 'u32' and '*const [5:0]u8'
38// :9:17: note: type 'u32' here
39// :9:20: note: type '*const [5:0]u8' here
40// :14:9: error: struct field 'bar' has conflicting types
41// :14:9: note: struct field '1' has conflicting types
42// :14:9: note: incompatible types: 'comptime_int' and '*const [2:0]u8'
43// :14:17: note: type 'comptime_int' here
44// :14:20: note: type '*const [2:0]u8' here
45// :19:9: error: incompatible types: '[]const u8' and '[*:0]const u8'
46// :19:17: note: type '[]const u8' here
47// :19:20: note: type '[*:0]const u8' here
48// :26:9: error: incompatible types: '[]const u8' and '[*]const u8'
49// :26:23: note: type '[]const u8' here
50// :26:26: note: type '[*]const u8' here
35// :5:9: error: incompatible types: '?@Vector(10, i32)' and '@Vector(11, i32)'
36// :5:17: note: type '?@Vector(10, i32)' here
37// :5:20: note: type '@Vector(11, i32)' here
38// :11:9: error: struct field '1' has conflicting types
39// :11:9: note: incompatible types: 'u32' and '*const [5:0]u8'
40// :11:17: note: type 'u32' here
41// :11:20: note: type '*const [5:0]u8' here
42// :16:9: error: struct field 'bar' has conflicting types
43// :16:9: note: struct field '1' has conflicting types
44// :16:9: note: incompatible types: 'comptime_int' and '*const [2:0]u8'
45// :16:17: note: type 'comptime_int' here
46// :16:20: note: type '*const [2:0]u8' here
47// :21:9: error: incompatible types: '[]const u8' and '[*:0]const u8'
48// :21:17: note: type '[]const u8' here
49// :21:20: note: type '[*:0]const u8' here
50// :28:9: error: incompatible types: '[]const u8' and '[*]const u8'
51// :28:23: note: type '[]const u8' here
52// :28:26: note: type '[*]const u8' here
test/cases/compile_errors/invalid_store_to_comptime_field.zig+13-11
......@@ -17,8 +17,9 @@ pub export fn entry2() void {
1717 var list = .{ 1, 2, 3 };
1818 var list2 = @TypeOf(list){ .@"0" = 1, .@"1" = 2, .@"2" = 3 };
1919 var list3 = @TypeOf(list){ 1, 2, 4 };
20 _ = list2;
21 _ = list3;
20 _ = &list;
21 _ = &list2;
22 _ = &list3;
2223}
2324pub export fn entry3() void {
2425 const U = struct {
......@@ -46,6 +47,7 @@ pub export fn entry5() void {
4647}
4748pub export fn entry6() void {
4849 var x: u32 = 15;
50 _ = &x;
4951 const T = @TypeOf(.{ @as(i32, -1234), @as(u32, 5678), x });
5052 const S = struct {
5153 fn foo(_: T) void {}
......@@ -74,12 +76,12 @@ pub export fn entry8() void {
7476// :6:9: error: value stored in comptime field does not match the default value of the field
7577// :14:9: error: value stored in comptime field does not match the default value of the field
7678// :19:38: error: value stored in comptime field does not match the default value of the field
77// :31:19: error: value stored in comptime field does not match the default value of the field
78// :25:29: note: default value set here
79// :41:19: error: value stored in comptime field does not match the default value of the field
80// :35:29: note: default value set here
81// :45:12: error: value stored in comptime field does not match the default value of the field
82// :53:25: error: value stored in comptime field does not match the default value of the field
83// :66:36: error: value stored in comptime field does not match the default value of the field
84// :59:30: error: value stored in comptime field does not match the default value of the field
85// :57:29: note: default value set here
79// :32:19: error: value stored in comptime field does not match the default value of the field
80// :26:29: note: default value set here
81// :42:19: error: value stored in comptime field does not match the default value of the field
82// :36:29: note: default value set here
83// :46:12: error: value stored in comptime field does not match the default value of the field
84// :55:25: error: value stored in comptime field does not match the default value of the field
85// :68:36: error: value stored in comptime field does not match the default value of the field
86// :61:30: error: value stored in comptime field does not match the default value of the field
87// :59:29: note: default value set here
test/cases/compile_errors/invalid_struct_field.zig+3-2
......@@ -8,6 +8,7 @@ export fn f() void {
88export fn g() void {
99 var a: A = undefined;
1010 const y = a.bar;
11 _ = &a;
1112 _ = y;
1213}
1314export fn e() void {
......@@ -26,5 +27,5 @@ export fn e() void {
2627// :1:11: note: struct declared here
2728// :10:17: error: no field named 'bar' in struct 'tmp.A'
2829// :1:11: note: struct declared here
29// :18:45: error: no field named 'f' in struct 'tmp.e.B'
30// :14:15: note: struct declared here
30// :19:45: error: no field named 'f' in struct 'tmp.e.B'
31// :15:15: note: struct declared here
test/cases/compile_errors/issue_2032_compile_diagnostic_string_for_top_level_decl_type.zig+2-2
......@@ -1,5 +1,5 @@
11export fn entry() void {
2 var foo: u32 = @This(){};
2 const foo: u32 = @This(){};
33 _ = foo;
44}
55
......@@ -7,5 +7,5 @@ export fn entry() void {
77// backend=stage2
88// target=native
99//
10// :2:27: error: expected type 'u32', found 'tmp'
10// :2:29: error: expected type 'u32', found 'tmp'
1111// :1:1: note: struct declared here
test/cases/compile_errors/issue_3818_bitcast_from_parray-slice_to_u16.zig+1-1
......@@ -4,7 +4,7 @@ export fn foo1() void {
44 _ = word;
55}
66export fn foo2() void {
7 var bytes: []const u8 = &[_]u8{ 1, 2 };
7 const bytes: []const u8 = &[_]u8{ 1, 2 };
88 const word: u16 = @bitCast(bytes);
99 _ = word;
1010}
test/cases/compile_errors/issue_5618_coercion_of_optional_anyopaque_to_anyopaque_must_fail.zig+5-5
......@@ -1,14 +1,14 @@
11export fn foo() void {
22 var u: ?*anyopaque = null;
33 var v: *anyopaque = undefined;
4 v = u;
4 v = (&u).*;
55}
66
77// error
88// backend=stage2
99// target=native
1010//
11// :4:9: error: expected type '*anyopaque', found '?*anyopaque'
12// :4:9: note: cannot convert optional to payload type
13// :4:9: note: consider using '.?', 'orelse', or 'if'
14// :4:9: note: '?*anyopaque' could have null values which are illegal in type '*anyopaque'
11// :4:13: error: expected type '*anyopaque', found '?*anyopaque'
12// :4:13: note: cannot convert optional to payload type
13// :4:13: note: consider using '.?', 'orelse', or 'if'
14// :4:13: note: '?*anyopaque' could have null values which are illegal in type '*anyopaque'
test/cases/compile_errors/lazy_pointer_with_undefined_element_type.zig+2-1
......@@ -1,5 +1,6 @@
11export fn foo() void {
22 comptime var T: type = undefined;
3 _ = &T;
34 const S = struct { x: *T };
45 const I = @typeInfo(S);
56 _ = I;
......@@ -9,4 +10,4 @@ export fn foo() void {
910// backend=stage2
1011// target=native
1112//
12// :3:28: error: use of undefined value here causes undefined behavior
13// :4:28: error: use of undefined value here causes undefined behavior
test/cases/compile_errors/load_vector_pointer_with_unknown_runtime_index.zig+1-1
......@@ -3,7 +3,7 @@ export fn entry() void {
33
44 var i: u32 = 0;
55 var x = loadv(&v[i]);
6 _ = x;
6 _ = .{ &i, &x };
77}
88
99fn loadv(ptr: anytype) i31 {
test/cases/compile_errors/memset_no_length.zig+6-4
......@@ -1,9 +1,11 @@
11export fn foo() void {
22 var ptr: [*]u8 = undefined;
3 _ = &ptr;
34 @memset(ptr, 123);
45}
56export fn bar() void {
67 var ptr: [*c]bool = undefined;
8 _ = &ptr;
79 @memset(ptr, true);
810}
911
......@@ -11,7 +13,7 @@ export fn bar() void {
1113// backend=stage2
1214// target=native
1315//
14// :3:5: error: unknown @memset length
15// :3:13: note: destination type '[*]u8' provides no length
16// :7:5: error: unknown @memset length
17// :7:13: note: destination type '[*c]bool' provides no length
16// :4:5: error: unknown @memset length
17// :4:13: note: destination type '[*]u8' provides no length
18// :9:5: error: unknown @memset length
19// :9:13: note: destination type '[*c]bool' provides no length
test/cases/compile_errors/missing_const_in_slice_with_nested_array_type.zig+1-1
......@@ -7,7 +7,7 @@ pub fn getGeo3DTex2D() Geo3DTex2D {
77 };
88}
99export fn entry() void {
10 var geo_data = getGeo3DTex2D();
10 const geo_data = getGeo3DTex2D();
1111 _ = geo_data;
1212}
1313
test/cases/compile_errors/missing_else_clause.zig+2-2
......@@ -14,7 +14,7 @@ fn h() void {
1414 // https://github.com/ziglang/zig/issues/12743
1515 const T = struct { oh_no: *u32 };
1616 var x: T = if (false) {};
17 _ = x;
17 _ = &x;
1818}
1919fn k(b: bool) void {
2020 // block_ptr case
......@@ -22,7 +22,7 @@ fn k(b: bool) void {
2222 var x = if (b) blk: {
2323 break :blk if (false) T{ .oh_no = 2 };
2424 } else T{ .oh_no = 1 };
25 _ = x;
25 _ = &x;
2626}
2727export fn entry() void {
2828 f(true);
test/cases/compile_errors/missing_parameter_name_of_generic_function.zig+1-1
......@@ -1,7 +1,7 @@
11fn dump(anytype) void {}
22export fn entry() void {
33 var a: u8 = 9;
4 dump(a);
4 dump((&a).*);
55}
66
77// error
test/cases/compile_errors/misspelled_type_with_pointer_only_reference.zig+1-1
......@@ -24,7 +24,7 @@ pub const JsonNode = struct {
2424fn foo() void {
2525 var jll: JasonList = undefined;
2626 jll.init(1234);
27 var jd = JsonNode{ .kind = JsonType.JSONArray, .jobject = JsonOA.JSONArray{jll} };
27 const jd = JsonNode{ .kind = JsonType.JSONArray, .jobject = JsonOA.JSONArray{jll} };
2828 _ = jd;
2929}
3030
test/cases/compile_errors/mod_on_undefined_value.zig+1
......@@ -1,6 +1,7 @@
11comptime {
22 var a: i64 = undefined;
33 _ = a % a;
4 _ = &a;
45}
56
67// error
test/cases/compile_errors/mult_on_undefined_value.zig+1-1
......@@ -1,5 +1,5 @@
11comptime {
2 var a: i64 = undefined;
2 const a: i64 = undefined;
33 _ = a * a;
44}
55
test/cases/compile_errors/negate_on_undefined_value.zig+1-1
......@@ -1,5 +1,5 @@
11comptime {
2 var a: i64 = undefined;
2 const a: i64 = undefined;
33 _ = -a;
44}
55
test/cases/compile_errors/nested_vectors.zig+1-1
......@@ -1,7 +1,7 @@
11export fn entry() void {
22 const V1 = @Vector(4, u8);
33 const V2 = @Type(.{ .Vector = .{ .len = 4, .child = V1 } });
4 var v: V2 = undefined;
4 const v: V2 = undefined;
55 _ = v;
66}
77
test/cases/compile_errors/non-const_variables_of_things_that_require_const_variables.zig+7-7
......@@ -1,30 +1,30 @@
11export fn entry1() void {
22 var m2 = &2;
3 _ = m2;
3 _ = &m2;
44}
55export fn entry2() void {
66 var a = undefined;
7 _ = a;
7 _ = &a;
88}
99export fn entry3() void {
1010 var b = 1;
11 _ = b;
11 _ = &b;
1212}
1313export fn entry4() void {
1414 var c = 1.0;
15 _ = c;
15 _ = &c;
1616}
1717export fn entry5() void {
1818 var d = null;
19 _ = d;
19 _ = &d;
2020}
2121export fn entry6(opaque_: *Opaque) void {
2222 var e = opaque_.*;
23 _ = e;
23 _ = &e;
2424}
2525export fn entry7() void {
2626 var f = i32;
27 _ = f;
27 _ = &f;
2828}
2929const Opaque = opaque {};
3030export fn entry8() void {
test/cases/compile_errors/non-integer_tag_type_to_enum.zig+1-1
......@@ -3,7 +3,7 @@ const Foo = enum(f32) {
33};
44export fn entry() void {
55 var f: Foo = undefined;
6 _ = f;
6 _ = &f;
77}
88
99// error
test/cases/compile_errors/non_void_error_union_payload_ignored.zig+4-2
......@@ -5,6 +5,7 @@ pub export fn entry1() void {
55 } else |_| {
66 // bar
77 }
8 _ = &x;
89}
910pub export fn entry2() void {
1011 var x: anyerror!usize = 5;
......@@ -13,6 +14,7 @@ pub export fn entry2() void {
1314 } else |_| {
1415 // bar
1516 }
17 _ = &x;
1618}
1719
1820// error
......@@ -21,5 +23,5 @@ pub export fn entry2() void {
2123//
2224// :3:5: error: error union payload is ignored
2325// :3:5: note: payload value can be explicitly ignored with '|_|'
24// :11:5: error: error union payload is ignored
25// :11:5: note: payload value can be explicitly ignored with '|_|'
26// :12:5: error: error union payload is ignored
27// :12:5: note: payload value can be explicitly ignored with '|_|'
test/cases/compile_errors/not_an_enum_type.zig+1-1
......@@ -1,6 +1,6 @@
11export fn entry() void {
22 var self: Error = undefined;
3 switch (self) {
3 switch ((&self).*) {
44 InvalidToken => |x| return x.token,
55 ExpectedVarDeclOrFn => |x| return x.token,
66 }
test/cases/compile_errors/or_on_undefined_value.zig+2-1
......@@ -1,5 +1,6 @@
11comptime {
22 var a: bool = undefined;
3 _ = &a;
34 _ = a or a;
45}
56
......@@ -7,4 +8,4 @@ comptime {
78// backend=stage2
89// target=native
910//
10// :3:9: error: use of undefined value here causes undefined behavior
11// :4:9: error: use of undefined value here causes undefined behavior
test/cases/compile_errors/orelse_on_undefined_value.zig+1-1
......@@ -1,5 +1,5 @@
11comptime {
2 var a: ?bool = undefined;
2 const a: ?bool = undefined;
33 _ = a orelse false;
44}
55
test/cases/compile_errors/out_of_bounds_index.zig+8-8
......@@ -1,29 +1,29 @@
11comptime {
22 var array = [_:0]u8{ 1, 2, 3, 4 };
33 var src_slice: [:0]u8 = &array;
4 var slice = src_slice[2..6];
4 const slice = src_slice[2..6];
55 _ = slice;
66}
77comptime {
88 var array = [_:0]u8{ 1, 2, 3, 4 };
9 var slice = array[2..6];
9 const slice = array[2..6];
1010 _ = slice;
1111}
1212comptime {
1313 var array = [_]u8{ 1, 2, 3, 4 };
14 var slice = array[2..5];
14 const slice = array[2..5];
1515 _ = slice;
1616}
1717comptime {
1818 var array = [_:0]u8{ 1, 2, 3, 4 };
19 var slice = array[3..2];
19 const slice = array[3..2];
2020 _ = slice;
2121}
2222
2323// error
2424// target=native
2525//
26// :4:30: error: end index 6 out of bounds for slice of length 4 +1 (sentinel)
27// :9:26: error: end index 6 out of bounds for array of length 4 +1 (sentinel)
28// :14:26: error: end index 5 out of bounds for array of length 4
29// :19:23: error: start index 3 is larger than end index 2
26// :4:32: error: end index 6 out of bounds for slice of length 4 +1 (sentinel)
27// :9:28: error: end index 6 out of bounds for array of length 4 +1 (sentinel)
28// :14:28: error: end index 5 out of bounds for array of length 4
29// :19:25: error: start index 3 is larger than end index 2
test/cases/compile_errors/overflow_in_enum_value_allocation.zig+1-1
......@@ -3,7 +3,7 @@ const Moo = enum(u8) {
33 Over,
44};
55pub export fn entry() void {
6 var y = Moo.Last;
6 const y = Moo.Last;
77 _ = y;
88}
99
test/cases/compile_errors/packed_union_given_enum_tag_type.zig+1-1
......@@ -9,7 +9,7 @@ const Payload = packed union(Letter) {
99 C: bool,
1010};
1111export fn entry() void {
12 var a = Payload{ .A = 1234 };
12 const a: Payload = .{ .A = 1234 };
1313 _ = a;
1414}
1515
test/cases/compile_errors/packed_union_with_automatic_layout_field.zig+1-1
......@@ -7,7 +7,7 @@ const Payload = packed union {
77 B: bool,
88};
99export fn entry() void {
10 var a = Payload{ .B = true };
10 const a: Payload = .{ .B = true };
1111 _ = a;
1212}
1313
test/cases/compile_errors/pointer_arithmetic_on_pointer-to-array.zig+5-5
......@@ -1,7 +1,7 @@
11export fn foo() void {
22 var x: [10]u8 = undefined;
3 var y = &x;
4 var z = y + 1;
3 const y = &x;
4 const z = y + 1;
55 _ = z;
66}
77
......@@ -9,6 +9,6 @@ export fn foo() void {
99// backend=stage2
1010// target=native
1111//
12// :4:15: error: incompatible types: '*[10]u8' and 'comptime_int'
13// :4:13: note: type '*[10]u8' here
14// :4:17: note: type 'comptime_int' here
12// :4:17: error: incompatible types: '*[10]u8' and 'comptime_int'
13// :4:15: note: type '*[10]u8' here
14// :4:19: note: type 'comptime_int' here
test/cases/compile_errors/pointer_to_anyopaque_slice.zig+1
......@@ -2,6 +2,7 @@ export fn x() void {
22 var a: *u32 = undefined;
33 var b: []anyopaque = undefined;
44 b = a;
5 _ = &a;
56}
67
78// error
test/cases/compile_errors/ptrFromInt_with_misaligned_address.zig+1-1
......@@ -1,6 +1,6 @@
11pub export fn entry() void {
22 var y: [*]align(4) u8 = @ptrFromInt(5);
3 _ = y;
3 _ = &y;
44}
55
66// error
test/cases/compile_errors/recursive_inline_fn.zig+2-1
......@@ -8,6 +8,7 @@ inline fn foo(x: i32) i32 {
88
99pub export fn entry() void {
1010 var x: i32 = 4;
11 _ = &x;
1112 _ = foo(x) == 20;
1213}
1314
......@@ -32,4 +33,4 @@ pub export fn entry2() void {
3233// target=native
3334//
3435// :5:27: error: inline call is recursive
35// :23:10: error: inline call is recursive
36// :24:10: error: inline call is recursive
test/cases/compile_errors/reference_to_const_data.zig+6-3
......@@ -5,10 +5,12 @@ export fn foo() void {
55export fn bar() void {
66 var ptr = &@as(u32, 2);
77 ptr.* = 2;
8 _ = &ptr;
89}
910export fn baz() void {
1011 var ptr = &true;
1112 ptr.* = false;
13 _ = &ptr;
1214}
1315export fn qux() void {
1416 const S = struct {
......@@ -21,6 +23,7 @@ export fn qux() void {
2123export fn quux() void {
2224 var x = &@returnAddress();
2325 x.* = 6;
26 _ = &x;
2427}
2528
2629// error
......@@ -29,6 +32,6 @@ export fn quux() void {
2932//
3033// :3:8: error: cannot assign to constant
3134// :7:8: error: cannot assign to constant
32// :11:8: error: cannot assign to constant
33// :19:8: error: cannot assign to constant
34// :23:6: error: cannot assign to constant
35// :12:8: error: cannot assign to constant
36// :21:8: error: cannot assign to constant
37// :25:6: error: cannot assign to constant
test/cases/compile_errors/reify_typeOf_with_incompatible_arguments.zig+1
......@@ -2,6 +2,7 @@ export fn entry() void {
22 var var_1: f32 = undefined;
33 var var_2: u32 = undefined;
44 _ = @TypeOf(var_1, var_2);
5 _ = .{ &var_1, &var_2 };
56}
67
78// error
test/cases/compile_errors/result_location_incompatibility_mismatching_handle_is_ptr.zig+1-1
......@@ -1,5 +1,5 @@
11export fn entry() void {
2 var damn = Container{
2 const damn = Container{
33 .not_optional = getOptional(),
44 };
55 _ = damn;
test/cases/compile_errors/result_location_incompatibility_mismatching_handle_is_ptr_generic_call.zig+1-1
......@@ -2,7 +2,7 @@ export fn entry() void {
22 var damn = Container{
33 .not_optional = getOptional(i32),
44 };
5 _ = damn;
5 _ = &damn;
66}
77pub fn getOptional(comptime T: type) ?T {
88 return 0;
test/cases/compile_errors/runtime_assignment_to_comptime_struct_type.zig+1
......@@ -5,6 +5,7 @@ const Foo = struct {
55export fn f() void {
66 var x: u8 = 0;
77 const foo = Foo{ .Bar = x, .Baz = u8 };
8 _ = &x;
89 _ = foo;
910}
1011
test/cases/compile_errors/runtime_assignment_to_comptime_union_type.zig+3-2
......@@ -4,6 +4,7 @@ const Foo = union {
44};
55export fn f() void {
66 var x: u8 = 0;
7 _ = &x;
78 const foo = Foo{ .Bar = x };
89 _ = foo;
910}
......@@ -12,5 +13,5 @@ export fn f() void {
1213// backend=stage2
1314// target=native
1415//
15// :7:23: error: unable to resolve comptime value
16// :7:23: note: initializer of comptime only union must be comptime-known
16// :8:23: error: unable to resolve comptime value
17// :8:23: note: initializer of comptime only union must be comptime-known
test/cases/compile_errors/runtime_cast_to_union_which_has_non-void_fields.zig+2-2
......@@ -8,7 +8,7 @@ export fn entry() void {
88 foo(Letter.A);
99}
1010fn foo(l: Letter) void {
11 var x: Value = l;
11 const x: Value = l;
1212 _ = x;
1313}
1414
......@@ -16,6 +16,6 @@ fn foo(l: Letter) void {
1616// backend=stage2
1717// target=native
1818//
19// :11:20: error: runtime coercion from enum 'tmp.Letter' to union 'tmp.Value' which has non-void fields
19// :11:22: error: runtime coercion from enum 'tmp.Letter' to union 'tmp.Value' which has non-void fields
2020// :3:5: note: field 'A' has type 'i32'
2121// :2:15: note: union declared here
test/cases/compile_errors/runtime_indexing_comptime_array.zig+4-2
......@@ -13,12 +13,14 @@ pub export fn entry2() void {
1313 const test_fns = [_]TestFn{ foo, bar };
1414 var i: usize = 0;
1515 _ = test_fns[i];
16 _ = &i;
1617}
1718pub export fn entry3() void {
1819 const TestFn = fn () void;
1920 const test_fns = [_]TestFn{ foo, bar };
2021 var i: usize = 0;
2122 _ = &test_fns[i];
23 _ = &i;
2224}
2325// error
2426// target=native
......@@ -28,5 +30,5 @@ pub export fn entry3() void {
2830// :7:10: note: use '*const fn () void' for a function pointer type
2931// :15:18: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
3032// :15:17: note: use '*const fn () void' for a function pointer type
31// :21:19: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
32// :21:18: note: use '*const fn () void' for a function pointer type
33// :22:19: error: values of type '[2]fn () void' must be comptime-known, but index value is runtime-known
34// :22:18: note: use '*const fn () void' for a function pointer type
test/cases/compile_errors/runtime_to_comptime_num.zig+12-8
......@@ -1,19 +1,23 @@
11pub export fn entry() void {
22 var a: u32 = 0;
3 _ = &a;
34 _ = @as(comptime_int, a);
45}
56pub export fn entry2() void {
67 var a: u32 = 0;
8 _ = &a;
79 _ = @as(comptime_float, a);
810}
911pub export fn entry3() void {
1012 comptime var aa: comptime_float = 0.0;
1113 var a: f32 = 4;
14 _ = &a;
1215 aa = a;
1316}
1417pub export fn entry4() void {
1518 comptime var aa: comptime_int = 0.0;
1619 var a: f32 = 4;
20 _ = &a;
1721 aa = a;
1822}
1923
......@@ -21,11 +25,11 @@ pub export fn entry4() void {
2125// backend=stage2
2226// target=native
2327//
24// :3:27: error: unable to resolve comptime value
25// :3:27: note: value being casted to 'comptime_int' must be comptime-known
26// :7:29: error: unable to resolve comptime value
27// :7:29: note: value being casted to 'comptime_float' must be comptime-known
28// :12:10: error: unable to resolve comptime value
29// :12:10: note: value being casted to 'comptime_float' must be comptime-known
30// :17:10: error: unable to resolve comptime value
31// :17:10: note: value being casted to 'comptime_int' must be comptime-known
28// :4:27: error: unable to resolve comptime value
29// :4:27: note: value being casted to 'comptime_int' must be comptime-known
30// :9:29: error: unable to resolve comptime value
31// :9:29: note: value being casted to 'comptime_float' must be comptime-known
32// :15:10: error: unable to resolve comptime value
33// :15:10: note: value being casted to 'comptime_float' must be comptime-known
34// :21:10: error: unable to resolve comptime value
35// :21:10: note: value being casted to 'comptime_int' must be comptime-known
test/cases/compile_errors/runtime_value_in_switch_prong.zig+1-1
......@@ -1,6 +1,6 @@
11pub export fn entry() void {
22 var byte: u8 = 1;
3 switch (byte) {
3 switch ((&byte).*) {
44 byte => {},
55 else => {},
66 }
test/cases/compile_errors/self_referential_struct_requires_comptime.zig+1-1
......@@ -4,7 +4,7 @@ const S = struct {
44};
55pub export fn entry() void {
66 var s: S = undefined;
7 _ = s;
7 _ = &s;
88}
99
1010// error
test/cases/compile_errors/self_referential_union_requires_comptime.zig+1-1
......@@ -4,7 +4,7 @@ const U = union {
44};
55pub export fn entry() void {
66 var u: U = undefined;
7 _ = u;
7 _ = &u;
88}
99
1010// error
test/cases/compile_errors/shift_by_negative_comptime_integer.zig+2-2
......@@ -1,5 +1,5 @@
11comptime {
2 var a = 1 >> -1;
2 const a = 1 >> -1;
33 _ = a;
44}
55
......@@ -7,4 +7,4 @@ comptime {
77// backend=stage2
88// target=native
99//
10// :2:18: error: shift by negative amount '-1'
10// :2:20: error: shift by negative amount '-1'
test/cases/compile_errors/shift_on_type_with_non-power-of-two_size.zig+8-4
......@@ -2,18 +2,22 @@ export fn entry() void {
22 const S = struct {
33 fn a() void {
44 var x: u24 = 42;
5 _ = &x;
56 _ = x >> 24;
67 }
78 fn b() void {
89 var x: u24 = 42;
10 _ = &x;
911 _ = x << 24;
1012 }
1113 fn c() void {
1214 var x: u24 = 42;
15 _ = &x;
1316 _ = @shlExact(x, 24);
1417 }
1518 fn d() void {
1619 var x: u24 = 42;
20 _ = &x;
1721 _ = @shrExact(x, 24);
1822 }
1923 };
......@@ -27,7 +31,7 @@ export fn entry() void {
2731// backend=stage2
2832// target=native
2933//
30// :5:22: error: shift amount '24' is too large for operand type 'u24'
31// :9:22: error: shift amount '24' is too large for operand type 'u24'
32// :13:30: error: shift amount '24' is too large for operand type 'u24'
33// :17:30: error: shift amount '24' is too large for operand type 'u24'
34// :6:22: error: shift amount '24' is too large for operand type 'u24'
35// :11:22: error: shift amount '24' is too large for operand type 'u24'
36// :16:30: error: shift amount '24' is too large for operand type 'u24'
37// :21:30: error: shift amount '24' is too large for operand type 'u24'
test/cases/compile_errors/shifting_without_int_type_or_comptime_known.zig+4-2
......@@ -6,10 +6,12 @@ export fn entry1(x: u8) u8 {
66}
77export fn entry2() void {
88 var x: u5 = 1;
9 _ = &x;
910 _ = @shlExact(12345, x);
1011}
1112export fn entry3() void {
1213 var x: u5 = 1;
14 _ = &x;
1315 _ = @shrExact(12345, x);
1416}
1517
......@@ -19,5 +21,5 @@ export fn entry3() void {
1921//
2022// :2:17: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
2123// :5:17: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
22// :9:9: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
23// :13:9: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
24// :10:9: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
25// :15:9: error: LHS of shift must be a fixed-width integer type, or RHS must be comptime-known
test/cases/compile_errors/shuffle_with_selected_index_past_first_vector_length.zig+4-4
......@@ -1,7 +1,7 @@
11export fn entry() void {
22 const v: @Vector(4, u32) = [4]u32{ 10, 11, 12, 13 };
33 const x: @Vector(4, u32) = [4]u32{ 14, 15, 16, 17 };
4 var z = @shuffle(u32, v, x, [8]i32{ 0, 1, 2, 3, 7, 6, 5, 4 });
4 const z = @shuffle(u32, v, x, [8]i32{ 0, 1, 2, 3, 7, 6, 5, 4 });
55 _ = z;
66}
77
......@@ -9,6 +9,6 @@ export fn entry() void {
99// backend=stage2
1010// target=native
1111//
12// :4:39: error: mask index '4' has out-of-bounds selection
13// :4:27: note: selected index '7' out of bounds of '@Vector(4, u32)'
14// :4:30: note: selections from the second vector are specified with negative numbers
12// :4:41: error: mask index '4' has out-of-bounds selection
13// :4:29: note: selected index '7' out of bounds of '@Vector(4, u32)'
14// :4:32: note: selections from the second vector are specified with negative numbers
test/cases/compile_errors/slice_cannot_have_its_bytes_reinterpreted.zig+2-3
......@@ -1,11 +1,10 @@
11export fn foo() void {
22 const bytes align(@alignOf([]const u8)) = [1]u8{0xfa} ** 16;
3 var value = @as(*const []const u8, @ptrCast(&bytes)).*;
4 _ = value;
3 _ = @as(*const []const u8, @ptrCast(&bytes)).*;
54}
65
76// error
87// backend=stage2
98// target=native
109//
11// :3:57: error: comptime dereference requires '[]const u8' to have a well-defined layout, but it does not.
10// :3:49: error: comptime dereference requires '[]const u8' to have a well-defined layout, but it does not.
test/cases/compile_errors/slice_of_null_pointer.zig+3-3
......@@ -1,11 +1,11 @@
11comptime {
22 var x: [*c]u8 = null;
33 var runtime_len: usize = 0;
4 var y = x[0..runtime_len];
5 _ = y;
4 _ = &runtime_len;
5 _ = x[0..runtime_len];
66}
77
88// error
99// target=native
1010//
11// :4:14: error: slice of null pointer
11// :5:10: error: slice of null pointer
test/cases/compile_errors/slice_sentinel_mismatch-2.zig+1-1
......@@ -1,5 +1,5 @@
11fn foo() [:0]u8 {
2 var x: []u8 = undefined;
2 const x: []u8 = undefined;
33 return x;
44}
55comptime {
test/cases/compile_errors/specify_enum_tag_type_that_is_too_small.zig+1-2
......@@ -7,8 +7,7 @@ const Small = enum(u2) {
77};
88
99export fn entry() void {
10 var x = Small.One;
11 _ = x;
10 _ = Small.One;
1211}
1312
1413// error
test/cases/compile_errors/specify_non-integer_enum_tag_type.zig+1-1
......@@ -5,7 +5,7 @@ const Small = enum(f32) {
55};
66
77export fn entry() void {
8 var x = Small.One;
8 const x = Small.One;
99 _ = x;
1010}
1111
test/cases/compile_errors/stage1/obj/variable_in_inline_assembly_template_cannot_be_found.zig+1-1
......@@ -2,7 +2,7 @@ export fn entry() void {
22 var sp = asm volatile ("mov %[foo], sp"
33 : [bar] "=r" (-> usize),
44 );
5 _ = sp;
5 _ = &sp;
66}
77
88// error
test/cases/compile_errors/store_vector_pointer_with_unknown_runtime_index.zig+2-1
......@@ -2,6 +2,7 @@ export fn entry() void {
22 var v: @Vector(4, i31) = [_]i31{ 1, 5, 3, undefined };
33
44 var i: u32 = 0;
5 _ = &i;
56 storev(&v[i], 42);
67}
78
......@@ -13,4 +14,4 @@ fn storev(ptr: anytype, val: i31) void {
1314// backend=llvm
1415// target=native
1516//
16// :9:8: error: unable to determine vector element index of type '*align(16:0:4:?) i31'
17// :10:8: error: unable to determine vector element index of type '*align(16:0:4:?) i31'
test/cases/compile_errors/sub_on_undefined_value.zig+1-1
......@@ -1,5 +1,5 @@
11comptime {
2 var a: i64 = undefined;
2 const a: i64 = undefined;
33 _ = a - a;
44}
55
test/cases/compile_errors/switch_capture_incompatible_types.zig+2-2
......@@ -1,7 +1,7 @@
11export fn f() void {
22 const U = union(enum) { a: u32, b: *u8 };
33 var u: U = undefined;
4 switch (u) {
4 switch ((&u).*) {
55 .a, .b => |val| _ = val,
66 }
77}
......@@ -9,7 +9,7 @@ export fn f() void {
99export fn g() void {
1010 const U = union(enum) { a: u64, b: u32 };
1111 var u: U = undefined;
12 switch (u) {
12 switch ((&u).*) {
1313 .a, .b => |*ptr| _ = ptr,
1414 }
1515}
test/cases/compile_errors/switch_on_enum_with_1_field_with_no_prongs.zig+1-1
......@@ -1,7 +1,7 @@
11const Foo = enum { M };
22
33export fn entry() void {
4 var f = Foo.M;
4 const f = Foo.M;
55 switch (f) {}
66}
77
test/cases/compile_errors/switch_on_slice.zig+2-1
......@@ -1,5 +1,6 @@
11pub export fn entry() void {
22 var a: [:0]const u8 = "foo";
3 _ = &a;
34 switch (a) {
45 ("--version"), ("version") => unreachable,
56 else => {},
......@@ -10,4 +11,4 @@ pub export fn entry() void {
1011// backend=stage2
1112// target=native
1213//
13// :3:13: error: switch on type '[:0]const u8'
14// :4:13: error: switch on type '[:0]const u8'
test/cases/compile_errors/switch_ranges_endpoints_are_validated.zig+2-2
......@@ -1,12 +1,12 @@
11pub export fn entry1() void {
2 var x: i32 = 0;
2 const x: i32 = 0;
33 switch (x) {
44 6...1 => {},
55 else => unreachable,
66 }
77}
88pub export fn entr2() void {
9 var x: i32 = 0;
9 const x: i32 = 0;
1010 switch (x) {
1111 -1...-5 => {},
1212 else => unreachable,
test/cases/compile_errors/switch_with_overlapping_case_ranges.zig+1-1
......@@ -1,6 +1,6 @@
11export fn entry() void {
22 var q: u8 = 0;
3 switch (q) {
3 switch ((&q).*) {
44 1...2 => {},
55 0...255 => {},
66 }
test/cases/compile_errors/switching_with_exhaustive_enum_has___prong_.zig+1-1
......@@ -3,7 +3,7 @@ const E = enum {
33 b,
44};
55pub export fn entry() void {
6 var e: E = .b;
6 const e: E = .b;
77 switch (e) {
88 .a => {},
99 .b => {},
test/cases/compile_errors/switching_with_non-exhaustive_enums.zig+3-3
......@@ -8,21 +8,21 @@ const U = union(E) {
88 b: u32,
99};
1010pub export fn entry1() void {
11 var e: E = .b;
11 const e: E = .b;
1212 switch (e) { // error: switch not handling the tag `b`
1313 .a => {},
1414 _ => {},
1515 }
1616}
1717pub export fn entry2() void {
18 var e: E = .b;
18 const e: E = .b;
1919 switch (e) { // error: switch on non-exhaustive enum must include `else` or `_` prong
2020 .a => {},
2121 .b => {},
2222 }
2323}
2424pub export fn entry3() void {
25 var u = U{ .a = 2 };
25 const u = U{ .a = 2 };
2626 switch (u) { // error: `_` prong not allowed when switching on tagged union
2727 .a => {},
2828 .b => {},
test/cases/compile_errors/tagName_used_on_union_with_no_associated_enum_tag.zig+3-4
......@@ -3,14 +3,13 @@ const FloatInt = extern union {
33 Int: i32,
44};
55export fn entry() void {
6 var fi = FloatInt{ .Float = 123.45 };
7 var tagName = @tagName(fi);
8 _ = tagName;
6 const fi: FloatInt = .{ .Float = 123.45 };
7 _ = @tagName(fi);
98}
109
1110// error
1211// backend=stage2
1312// target=native
1413//
15// :7:19: error: union 'tmp.FloatInt' is untagged
14// :7:9: error: union 'tmp.FloatInt' is untagged
1615// :1:25: note: union declared here
test/cases/compile_errors/truncate_sign_mismatch.zig+8-8
......@@ -1,25 +1,25 @@
11export fn entry1() i8 {
22 var x: u32 = 10;
3 return @truncate(x);
3 return @truncate((&x).*);
44}
55export fn entry2() u8 {
66 var x: i32 = -10;
7 return @truncate(x);
7 return @truncate((&x).*);
88}
99export fn entry3() i8 {
1010 comptime var x: u32 = 10;
11 return @truncate(x);
11 return @truncate((&x).*);
1212}
1313export fn entry4() u8 {
1414 comptime var x: i32 = -10;
15 return @truncate(x);
15 return @truncate((&x).*);
1616}
1717
1818// error
1919// backend=stage2
2020// target=native
2121//
22// :3:22: error: expected signed integer type, found 'u32'
23// :7:22: error: expected unsigned integer type, found 'i32'
24// :11:22: error: expected signed integer type, found 'u32'
25// :15:22: error: expected unsigned integer type, found 'i32'
22// :3:26: error: expected signed integer type, found 'u32'
23// :7:26: error: expected unsigned integer type, found 'i32'
24// :11:26: error: expected signed integer type, found 'u32'
25// :15:26: error: expected unsigned integer type, found 'i32'
test/cases/compile_errors/tuple_init_edge_cases.zig+23-18
......@@ -1,49 +1,54 @@
11pub export fn entry1() void {
22 const T = @TypeOf(.{ 123, 3 });
33 var b = T{ .@"1" = 3 };
4 _ = b;
4 _ = &b;
55 var c = T{ 123, 3 };
6 _ = c;
6 _ = &c;
77 var d = T{};
8 _ = d;
8 _ = &d;
99}
1010pub export fn entry2() void {
1111 var a: u32 = 2;
12 _ = &a;
1213 const T = @TypeOf(.{ 123, a });
1314 var b = T{ .@"1" = 3 };
14 _ = b;
15 _ = &b;
1516 var c = T{ 123, 3 };
16 _ = c;
17 _ = &c;
1718 var d = T{};
18 _ = d;
19 _ = &d;
1920}
2021pub export fn entry3() void {
2122 var a: u32 = 2;
23 _ = &a;
2224 const T = @TypeOf(.{ 123, a });
2325 var b = T{ .@"0" = 123 };
24 _ = b;
26 _ = &b;
2527}
2628comptime {
2729 var a: u32 = 2;
30 _ = &a;
2831 const T = @TypeOf(.{ 123, a });
2932 var b = T{ .@"0" = 123 };
30 _ = b;
33 _ = &b;
3134 var c = T{ 123, 2 };
32 _ = c;
35 _ = &c;
3336 var d = T{};
34 _ = d;
37 _ = &d;
3538}
3639pub export fn entry4() void {
3740 var a: u32 = 2;
41 _ = &a;
3842 const T = @TypeOf(.{ 123, a });
3943 var b = T{ 123, 4, 5 };
40 _ = b;
44 _ = &b;
4145}
4246pub export fn entry5() void {
4347 var a: u32 = 2;
48 _ = &a;
4449 const T = @TypeOf(.{ 123, a });
4550 var b = T{ .@"0" = 123, .@"2" = 123, .@"1" = 123 };
46 _ = b;
51 _ = &b;
4752}
4853pub const Consideration = struct {
4954 curve: Curve,
......@@ -64,9 +69,9 @@ pub export fn entry6() void {
6469// backend=stage2
6570// target=native
6671//
67// :17:14: error: missing tuple field with index 1
68// :23:14: error: missing tuple field with index 1
69// :39:14: error: expected at most 2 tuple fields; found 3
70// :45:30: error: index '2' out of bounds of tuple 'struct{comptime comptime_int = 123, u32}'
71// :58:37: error: missing tuple field with index 3
72// :53:32: note: struct declared here
72// :18:14: error: missing tuple field with index 1
73// :25:14: error: missing tuple field with index 1
74// :43:14: error: expected at most 2 tuple fields; found 3
75// :50:30: error: index '2' out of bounds of tuple 'struct{comptime comptime_int = 123, u32}'
76// :63:37: error: missing tuple field with index 3
77// :58:32: note: struct declared here
test/cases/compile_errors/uncreachable_else_prong_err_set.zig deleted-25
......@@ -1,25 +0,0 @@
1pub export fn complex() void {
2 var a: error{ Foo, Bar } = error.Foo;
3 switch (a) {
4 error.Foo => unreachable,
5 error.Bar => unreachable,
6 else => {
7 @compileError("<something complex here>");
8 },
9 }
10}
11
12pub export fn simple() void {
13 var a: error{ Foo, Bar } = error.Foo;
14 switch (a) {
15 error.Foo => unreachable,
16 error.Bar => unreachable,
17 else => |e| return e,
18 }
19}
20
21// error
22// backend=llvm
23// target=native
24//
25// :6:14: error: unreachable else prong; all cases already handled
test/cases/compile_errors/union_access_of_inactive_field.zig+1
......@@ -5,6 +5,7 @@ const U = union {
55comptime {
66 var u: U = .{ .a = {} };
77 const v = u.b;
8 _ = &u;
89 _ = v;
910}
1011
test/cases/compile_errors/union_auto-enum_value_already_taken.zig+1-1
......@@ -6,7 +6,7 @@ const MultipleChoice = union(enum(u32)) {
66 E = 60,
77};
88export fn entry() void {
9 var x = MultipleChoice{ .C = {} };
9 const x: MultipleChoice = .{ .C = {} };
1010 _ = x;
1111}
1212
test/cases/compile_errors/union_duplicate_enum_field.zig+1-1
......@@ -5,7 +5,7 @@ const U = union(E) {
55};
66
77export fn foo() void {
8 var u: U = .{ .a = 123 };
8 const u: U = .{ .a = 123 };
99 _ = u;
1010}
1111
test/cases/compile_errors/union_enum_field_does_not_match_enum.zig+1-1
......@@ -10,7 +10,7 @@ const Payload = union(Letter) {
1010 D: bool,
1111};
1212export fn entry() void {
13 var a = Payload{ .A = 1234 };
13 const a: Payload = .{ .A = 1234 };
1414 _ = a;
1515}
1616
test/cases/compile_errors/union_noreturn_field_initialized.zig+3-3
......@@ -9,7 +9,7 @@ pub export fn entry1() void {
99 };
1010
1111 var a = U{ .b = undefined };
12 _ = a;
12 _ = &a;
1313}
1414pub export fn entry2() void {
1515 const U = union(enum) {
......@@ -25,7 +25,7 @@ pub export fn entry3() void {
2525 };
2626 var e = @typeInfo(U).Union.tag_type.?.a;
2727 var u: U = undefined;
28 u = e;
28 u = (&e).*;
2929}
3030
3131// error
......@@ -38,6 +38,6 @@ pub export fn entry3() void {
3838// :19:10: error: cannot initialize 'noreturn' field of union
3939// :16:9: note: field 'a' declared here
4040// :15:15: note: union declared here
41// :28:9: error: runtime coercion from enum '@typeInfo(tmp.entry3.U).Union.tag_type.?' to union 'tmp.entry3.U' which has a 'noreturn' field
41// :28:13: error: runtime coercion from enum '@typeInfo(tmp.entry3.U).Union.tag_type.?' to union 'tmp.entry3.U' which has a 'noreturn' field
4242// :23:9: note: 'noreturn' field here
4343// :22:15: note: union declared here
test/cases/compile_errors/union_runtime_coercion_from_enum.zig+1-1
......@@ -11,7 +11,7 @@ fn foo() E {
1111}
1212export fn doTheTest() u64 {
1313 var u: U = foo();
14 return u.b;
14 return (&u).b;
1515}
1616
1717// error
test/cases/compile_errors/unreachable_else_prong_err_set.zig created+27
......@@ -0,0 +1,27 @@
1pub export fn complex() void {
2 var a: error{ Foo, Bar } = error.Foo;
3 _ = &a;
4 switch (a) {
5 error.Foo => unreachable,
6 error.Bar => unreachable,
7 else => {
8 @compileError("<something complex here>");
9 },
10 }
11}
12
13pub export fn simple() void {
14 var a: error{ Foo, Bar } = error.Foo;
15 _ = &a;
16 switch (a) {
17 error.Foo => unreachable,
18 error.Bar => unreachable,
19 else => |e| return e,
20 }
21}
22
23// error
24// backend=llvm
25// target=native
26//
27// :7:14: error: unreachable else prong; all cases already handled
test/cases/compile_errors/use_implicit_casts_to_assign_null_to_non-nullable_pointer.zig+5-6
......@@ -1,16 +1,15 @@
11export fn entry() void {
22 var x: i32 = 1234;
33 var p: *i32 = &x;
4 var pp: *?*i32 = &p;
4 const pp: *?*i32 = &p;
55 pp.* = null;
6 var y = p.*;
7 _ = y;
6 _ = p.*;
87}
98
109// error
1110// backend=stage2
1211// target=native
1312//
14// :4:22: error: expected type '*?*i32', found '**i32'
15// :4:22: note: pointer type child '*i32' cannot cast into pointer type child '?*i32'
16// :4:22: note: mutable '*i32' allows illegal null values stored to type '?*i32'
13// :4:24: error: expected type '*?*i32', found '**i32'
14// :4:24: note: pointer type child '*i32' cannot cast into pointer type child '?*i32'
15// :4:24: note: mutable '*i32' allows illegal null values stored to type '?*i32'
test/cases/compile_errors/use_invalid_number_literal_as_array_index.zig+1-1
......@@ -1,7 +1,7 @@
11var v = 25;
22export fn entry() void {
33 var arr: [v]u8 = undefined;
4 _ = arr;
4 _ = &arr;
55}
66
77// error
test/cases/compile_errors/variable_with_type_noreturn.zig+1-1
......@@ -1,6 +1,6 @@
11export fn entry9() void {
22 var z: noreturn = return;
3 _ = z;
3 _ = &z;
44}
55
66// error
test/cases/compile_errors/variadic_arg_validation.zig+5-4
......@@ -7,6 +7,7 @@ pub export fn entry() void {
77pub export fn entry1() void {
88 var arr: [2]u8 = undefined;
99 _ = printf("%d\n", arr);
10 _ = &arr;
1011}
1112
1213pub export fn entry2() void {
......@@ -23,7 +24,7 @@ pub export fn entry3() void {
2324//
2425// :4:33: error: integer and float literals passed to variadic function must be casted to a fixed-size number type
2526// :9:24: error: arrays must be passed by reference to variadic function
26// :13:24: error: cannot pass 'u48' to variadic function
27// :13:24: note: only integers with 0 or power of two bits are extern compatible
28// :17:24: error: cannot pass 'void' to variadic function
29// :17:24: note: 'void' is a zero bit type; for C 'void' use 'anyopaque'
27// :14:24: error: cannot pass 'u48' to variadic function
28// :14:24: note: only integers with 0 or power of two bits are extern compatible
29// :18:24: error: cannot pass 'void' to variadic function
30// :18:24: note: 'void' is a zero bit type; for C 'void' use 'anyopaque'
test/cases/compile_errors/while_loop_body_expression_ignored.zig+16-12
......@@ -6,18 +6,22 @@ export fn f1() void {
66}
77export fn f2() void {
88 var x: ?i32 = null;
9 _ = &x;
910 while (x) |_| returns();
1011}
1112export fn f3() void {
1213 var x: anyerror!i32 = error.Bad;
14 _ = &x;
1315 while (x) |_| returns() else |_| unreachable;
1416}
1517export fn f4() void {
1618 var a = true;
19 _ = &a;
1720 while (a) {} else true;
1821}
1922export fn f5() void {
2023 var a = true;
24 _ = &a;
2125 const foo = while (a) returns() else true;
2226 _ = foo;
2327}
......@@ -29,15 +33,15 @@ export fn f5() void {
2933// :5:25: error: value of type 'usize' ignored
3034// :5:25: note: all non-void values must be used
3135// :5:25: note: this error can be suppressed by assigning the value to '_'
32// :9:26: error: value of type 'usize' ignored
33// :9:26: note: all non-void values must be used
34// :9:26: note: this error can be suppressed by assigning the value to '_'
35// :13:26: error: value of type 'usize' ignored
36// :13:26: note: all non-void values must be used
37// :13:26: note: this error can be suppressed by assigning the value to '_'
38// :17:23: error: value of type 'bool' ignored
39// :17:23: note: all non-void values must be used
40// :17:23: note: this error can be suppressed by assigning the value to '_'
41// :21:34: error: value of type 'usize' ignored
42// :21:34: note: all non-void values must be used
43// :21:34: note: this error can be suppressed by assigning the value to '_'
36// :10:26: error: value of type 'usize' ignored
37// :10:26: note: all non-void values must be used
38// :10:26: note: this error can be suppressed by assigning the value to '_'
39// :15:26: error: value of type 'usize' ignored
40// :15:26: note: all non-void values must be used
41// :15:26: note: this error can be suppressed by assigning the value to '_'
42// :20:23: error: value of type 'bool' ignored
43// :20:23: note: all non-void values must be used
44// :20:23: note: this error can be suppressed by assigning the value to '_'
45// :25:34: error: value of type 'usize' ignored
46// :25:34: note: all non-void values must be used
47// :25:34: note: this error can be suppressed by assigning the value to '_'
test/cases/compile_errors/while_loop_break_value_ignored.zig+4-2
......@@ -7,6 +7,7 @@ export fn f1() void {
77 while (a) {
88 break returns();
99 }
10 _ = &a;
1011}
1112
1213export fn f2() void {
......@@ -16,6 +17,7 @@ export fn f2() void {
1617 break :outer returns();
1718 }
1819 }
20 _ = &x;
1921}
2022
2123// error
......@@ -24,5 +26,5 @@ export fn f2() void {
2426//
2527// :7:5: error: incompatible types: 'usize' and 'void'
2628// :8:22: note: type 'usize' here
27// :14:12: error: incompatible types: 'usize' and 'void'
28// :16:33: note: type 'usize' here
29// :15:12: error: incompatible types: 'usize' and 'void'
30// :17:33: note: type 'usize' here
test/cases/compile_errors/wrong_type_passed_to_panic.zig+1-1
......@@ -1,5 +1,5 @@
11export fn entry() void {
2 var e = error.Foo;
2 const e = error.Foo;
33 @panic(e);
44}
55
test/cases/compile_log.0.zig+1-1
......@@ -4,7 +4,7 @@ export fn _start() noreturn {
44 @compileLog(b, 20, f, x);
55 @compileLog(1000);
66 var bruh: usize = true;
7 _ = bruh;
7 _ = .{ &f, &bruh };
88 unreachable;
99}
1010export fn other() void {
test/cases/compile_log.1.zig+1
......@@ -1,6 +1,7 @@
11export fn _start() noreturn {
22 const b = true;
33 var f: u32 = 1;
4 _ = &f;
45 @compileLog(b, 20, f, x);
56 @compileLog(1000);
67 unreachable;
test/cases/comptime_var.0.zig+3-2
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var a: u32 = 0;
3 _ = &a;
34 comptime var b: u32 = 0;
45 if (a == 0) b = 3;
56}
......@@ -9,5 +10,5 @@ pub fn main() void {
910// target=x86_64-macos,x86_64-linux
1011// link_libc=true
1112//
12// :4:19: error: store to comptime variable depends on runtime condition
13// :4:11: note: runtime condition here
13// :5:19: error: store to comptime variable depends on runtime condition
14// :5:11: note: runtime condition here
test/cases/comptime_var.1.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var a: u32 = 0;
3 _ = &a;
34 comptime var b: u32 = 0;
45 switch (a) {
56 0 => {},
test/cases/comptime_var.5.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var a: u32 = 0;
3 _ = &a;
34 if (a == 0) {
45 comptime var b: u32 = 0;
56 b = 1;
test/cases/conditions.5.zig+1
......@@ -10,6 +10,7 @@ fn assert(ok: bool) void {
1010fn foo(ok: bool) i32 {
1111 const val: i32 = blk: {
1212 var x: i32 = 1;
13 _ = &x;
1314 if (!ok) break :blk x + @as(i32, 9);
1415 break :blk x + @as(i32, 19);
1516 };
test/cases/decl_value_arena.zig+1-1
......@@ -14,7 +14,7 @@ pub const Connection = struct {
1414
1515pub fn main() void {
1616 var conn: Connection = undefined;
17 _ = conn;
17 _ = &conn;
1818}
1919
2020// run
test/cases/enum_values.0.zig+2-2
......@@ -4,8 +4,8 @@ pub fn main() void {
44 var number1 = Number.One;
55 var number2: Number = .Two;
66 if (false) {
7 number1;
8 number2;
7 &number1;
8 &number2;
99 }
1010 const number3: Number = @enumFromInt(2);
1111 if (@intFromEnum(number3) != 2) {
test/cases/enum_values.1.zig+3
......@@ -2,7 +2,9 @@ const Number = enum { One, Two, Three };
22
33pub fn main() void {
44 var number1 = Number.One;
5 _ = &number1;
56 var number2: Number = .Two;
7 _ = &number2;
68 const number3: Number = @enumFromInt(2);
79 assert(number1 != number2);
810 assert(number2 != number3);
......@@ -10,6 +12,7 @@ pub fn main() void {
1012 assert(@intFromEnum(number2) == 1);
1113 assert(@intFromEnum(number3) == 2);
1214 var x: Number = .Two;
15 _ = &x;
1316 assert(number2 == x);
1417
1518 return;
test/cases/error_in_nested_declaration.zig+1-1
......@@ -19,7 +19,7 @@ const S2 = struct {
1919
2020pub export fn entry2() void {
2121 var s: S2 = undefined;
22 _ = s;
22 _ = &s;
2323}
2424
2525// error
test/cases/error_unions.0.zig+1
......@@ -1,6 +1,7 @@
11pub fn main() void {
22 var e1 = error.Foo;
33 var e2 = error.Bar;
4 _ = .{ &e1, &e2 };
45 assert(e1 != e2);
56 assert(e1 == error.Foo);
67 assert(e2 == error.Bar);
test/cases/error_unions.1.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() u8 {
22 var e: anyerror!u8 = 5;
3 _ = &e;
34 const i = e catch 10;
45 return i - 5;
56}
test/cases/error_unions.2.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() u8 {
22 var e: anyerror!u8 = error.Foo;
3 _ = &e;
34 const i = e catch 10;
45 return i - 10;
56}
test/cases/error_unions.3.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() u8 {
22 var e = foo();
3 _ = &e;
34 const i = e catch 69;
45 return i - 5;
56}
test/cases/error_unions.4.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() u8 {
22 var e = foo();
3 _ = &e;
34 const i = e catch 69;
45 return i - 69;
56}
test/cases/error_unions.5.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() u8 {
22 var e = foo();
3 _ = &e;
34 const i = e catch 42;
45 return i - 42;
56}
test/cases/f32_passed_to_variadic_fn.zig+2-2
......@@ -2,8 +2,8 @@ extern fn printf(format: [*:0]const u8, ...) c_int;
22pub fn main() void {
33 var a: f64 = 2.0;
44 var b: f32 = 10.0;
5 _ = printf("f64: %f\n", a);
6 _ = printf("f32: %f\n", b);
5 _ = printf("f64: %f\n", (&a).*);
6 _ = printf("f32: %f\n", (&b).*);
77}
88
99// run
test/cases/inner_func_accessing_outer_var.zig+3-2
......@@ -1,5 +1,6 @@
11pub fn f() void {
22 var bar: bool = true;
3 _ = &bar;
34 const S = struct {
45 fn baz() bool {
56 return bar;
......@@ -10,6 +11,6 @@ pub fn f() void {
1011
1112// error
1213//
13// :5:20: error: mutable 'bar' not accessible from here
14// :6:20: error: mutable 'bar' not accessible from here
1415// :2:9: note: declared mutable here
15// :3:15: note: crosses namespace boundary here
16// :4:15: note: crosses namespace boundary here
test/cases/llvm/blocks.zig+1
......@@ -5,6 +5,7 @@ fn assert(ok: bool) void {
55fn foo(ok: bool) i32 {
66 const val: i32 = blk: {
77 var x: i32 = 1;
8 _ = &x;
89 if (!ok) break :blk x + 9;
910 break :blk x + 19;
1011 };
test/cases/llvm/f_segment_address_space_reading_and_writing.zig+1
......@@ -35,6 +35,7 @@ pub fn main() void {
3535 assert(getFs() == @intFromPtr(&test_value));
3636
3737 var test_ptr: *allowzero addrspace(.fs) u64 = @ptrFromInt(0);
38 _ = &test_ptr;
3839 assert(test_ptr.* == 12345);
3940 test_ptr.* = 98765;
4041 assert(test_value == 98765);
test/cases/llvm/nested_blocks.zig+1-1
......@@ -10,7 +10,7 @@ fn foo(ok: bool) i32 {
1010 };
1111 break :blk val2 + 10;
1212 };
13 return val;
13 return (&val).*;
1414}
1515
1616pub fn main() void {
test/cases/llvm/optionals.zig+4
......@@ -7,8 +7,10 @@ pub fn main() void {
77 var null_val: ?i32 = null;
88
99 var val1: i32 = opt_val.?;
10 _ = &val1;
1011 const val1_1: i32 = opt_val.?;
1112 var ptr_val1 = &(opt_val.?);
13 _ = &ptr_val1;
1214 const ptr_val1_1 = &(opt_val.?);
1315
1416 var val2: i32 = null_val orelse 20;
......@@ -16,9 +18,11 @@ pub fn main() void {
1618
1719 var value: i32 = 20;
1820 var ptr_val2 = &(null_val orelse value);
21 _ = &ptr_val2;
1922
2023 const val3 = opt_val orelse 30;
2124 var val3_var = opt_val orelse 30;
25 _ = &val3_var;
2226
2327 assert(val1 == 10);
2428 assert(val1_1 == 10);
test/cases/llvm/simple_addition_and_subtraction.zig+1
......@@ -4,6 +4,7 @@ fn add(a: i32, b: i32) i32 {
44
55pub fn main() void {
66 var a: i32 = -5;
7 _ = &a;
78 const x = add(a, 7);
89 var y = add(2, 0);
910 y -= x;
test/cases/locals.0.zig+2-2
......@@ -3,8 +3,8 @@ pub fn main() void {
33 var y: f32 = 42.0;
44 var x: u8 = 10;
55 if (false) {
6 y;
7 x;
6 &y;
7 &x / &i;
88 }
99 if (i != 5) unreachable;
1010}
test/cases/locals.1.zig+2-1
......@@ -1,8 +1,9 @@
11pub fn main() void {
22 var i: u8 = 5;
33 var y: f32 = 42.0;
4 _ = y;
4 _ = &y;
55 var x: u8 = 10;
6 _ = &x;
67 foo(i, x);
78 i = x;
89 if (i != 10) unreachable;
test/cases/multiplying_numbers_at_runtime_and_comptime.2.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var x: usize = 5;
3 _ = &x;
34 const y = mul(2, 3, x);
45 if (y - 30 != 0) unreachable;
56}
test/cases/only_1_function_and_it_gets_updated.1.zig+1-1
......@@ -1,6 +1,6 @@
11pub export fn _start() noreturn {
22 var dummy: u32 = 10;
3 _ = dummy;
3 _ = &dummy;
44 while (true) {}
55}
66
test/cases/optionals.0.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() u8 {
22 var x: ?u8 = 5;
3 _ = &x;
34 var y: u8 = 0;
45 if (x) |val| {
56 y = val;
test/cases/optionals.1.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() u8 {
22 var x: ?u8 = null;
3 _ = &x;
34 var y: u8 = 0;
45 if (x) |val| {
56 y = val;
test/cases/optionals.2.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() u8 {
22 var x: ?u8 = 5;
3 _ = &x;
34 return x.? - 5;
45}
56
test/cases/optionals.3.zig+1
......@@ -1,6 +1,7 @@
11pub fn main() u8 {
22 var x: u8 = 5;
33 var y: ?u8 = x;
4 _ = .{ &x, &y };
45 return y.? - 5;
56}
67
test/cases/runtime_bitwise_and.zig+1
......@@ -7,6 +7,7 @@ pub fn main() void {
77 var m2: u32 = 0b0000;
88 assert(m1 & 0b1010 == 0b1010);
99 assert(m2 & 0b1010 == 0b0000);
10 _ = .{ &i, &j, &m1, &m2 };
1011}
1112fn assert(b: bool) void {
1213 if (!b) unreachable;
test/cases/runtime_bitwise_or.zig+1
......@@ -7,6 +7,7 @@ pub fn main() void {
77 var m2: u32 = 0b0000;
88 assert(m1 | 0b1010 == 0b1111);
99 assert(m2 | 0b1010 == 0b1010);
10 _ = .{ &i, &j, &m1, &m2 };
1011}
1112fn assert(b: bool) void {
1213 if (!b) unreachable;
test/cases/safety/@asyncCall with too small a frame.zig +2-1
......@@ -13,8 +13,9 @@ pub fn main() !void {
1313 }
1414 var bytes: [1]u8 align(16) = undefined;
1515 var ptr = other;
16 _ = &ptr;
1617 var frame = @asyncCall(&bytes, {}, ptr, .{});
17 _ = frame;
18 _ = &frame;
1819 return error.TestFailed;
1920}
2021fn other() callconv(.Async) void {
test/cases/safety/@intCast to u0.zig +1-1
......@@ -14,7 +14,7 @@ pub fn main() !void {
1414}
1515
1616fn bar(one: u1, not_zero: i32) void {
17 var x = one << @as(u0, @intCast(not_zero));
17 const x = one << @intCast(not_zero);
1818 _ = x;
1919}
2020// run
test/cases/safety/@ptrFromInt address zero to non-optional byte-aligned pointer.zig +2-1
......@@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010pub fn main() !void {
1111 var zero: usize = 0;
12 var b: *u8 = @ptrFromInt(zero);
12 _ = &zero;
13 const b: *u8 = @ptrFromInt(zero);
1314 _ = b;
1415 return error.TestFailed;
1516}
test/cases/safety/@ptrFromInt address zero to non-optional pointer.zig +2-1
......@@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010pub fn main() !void {
1111 var zero: usize = 0;
12 var b: *i32 = @ptrFromInt(zero);
12 _ = &zero;
13 const b: *i32 = @ptrFromInt(zero);
1314 _ = b;
1415 return error.TestFailed;
1516}
test/cases/safety/@ptrFromInt with misaligned address.zig +2-1
......@@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010pub fn main() !void {
1111 var x: usize = 5;
12 var y: [*]align(4) u8 = @ptrFromInt(x);
12 _ = &x;
13 const y: [*]align(4) u8 = @ptrFromInt(x);
1314 _ = y;
1415 return error.TestFailed;
1516}
test/cases/safety/@tagName on corrupted enum value.zig +1-1
......@@ -16,7 +16,7 @@ const E = enum(u32) {
1616pub fn main() !void {
1717 var e: E = undefined;
1818 @memset(@as([*]u8, @ptrCast(&e))[0..@sizeOf(E)], 0x55);
19 var n = @tagName(e);
19 const n = @tagName(e);
2020 _ = n;
2121 return error.TestFailed;
2222}
test/cases/safety/@tagName on corrupted union value.zig +2-2
......@@ -16,8 +16,8 @@ const U = union(enum(u32)) {
1616pub fn main() !void {
1717 var u: U = undefined;
1818 @memset(@as([*]u8, @ptrCast(&u))[0..@sizeOf(U)], 0x55);
19 var t: @typeInfo(U).Union.tag_type.? = u;
20 var n = @tagName(t);
19 const t: @typeInfo(U).Union.tag_type.? = u;
20 const n = @tagName(t);
2121 _ = n;
2222 return error.TestFailed;
2323}
test/cases/safety/array slice sentinel mismatch non-scalar.zig +1-1
......@@ -11,7 +11,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1111pub fn main() !void {
1212 const S = struct { a: u32 };
1313 var arr = [_]S{ .{ .a = 1 }, .{ .a = 2 } };
14 var s = arr[0..1 :.{ .a = 1 }];
14 const s = arr[0..1 :.{ .a = 1 }];
1515 _ = s;
1616 return error.TestFailed;
1717}
test/cases/safety/exact division failure - vectors.zig +2-2
......@@ -9,8 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010
1111pub fn main() !void {
12 var a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 };
13 var b: @Vector(4, i32) = [4]i32{ 111, 222, 333, 441 };
12 const a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 };
13 const b: @Vector(4, i32) = [4]i32{ 111, 222, 333, 441 };
1414 const x = divExact(a, b);
1515 _ = x;
1616 return error.TestFailed;
test/cases/safety/for_len_mismatch.zig+1
......@@ -12,6 +12,7 @@ pub fn main() !void {
1212 var runtime_i: usize = 1;
1313 var j: usize = 3;
1414 var slice = "too long";
15 _ = .{ &runtime_i, &j, &slice };
1516 for (runtime_i..j, slice) |a, b| {
1617 _ = a;
1718 _ = b;
test/cases/safety/for_len_mismatch_three.zig+1
......@@ -10,6 +10,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1010
1111pub fn main() !void {
1212 var slice: []const u8 = "hello";
13 _ = &slice;
1314 for (10..20, slice, 20..30) |a, b, c| {
1415 _ = a;
1516 _ = b;
test/cases/safety/integer division by zero - vectors.zig +2-2
......@@ -8,8 +8,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
88 std.process.exit(1);
99}
1010pub fn main() !void {
11 var a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 };
12 var b: @Vector(4, i32) = [4]i32{ 111, 0, 333, 444 };
11 const a: @Vector(4, i32) = [4]i32{ 111, 222, 333, 444 };
12 const b: @Vector(4, i32) = [4]i32{ 111, 0, 333, 444 };
1313 const x = div0(a, b);
1414 _ = x;
1515 return error.TestFailed;
test/cases/safety/memcpy_alias.zig+1
......@@ -10,6 +10,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1010pub fn main() !void {
1111 var buffer = [2]u8{ 1, 2 } ** 5;
1212 var len: usize = 5;
13 _ = &len;
1314 @memcpy(buffer[0..len], buffer[4 .. 4 + len]);
1415}
1516// run
test/cases/safety/memcpy_len_mismatch.zig+1
......@@ -10,6 +10,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1010pub fn main() !void {
1111 var buffer = [2]u8{ 1, 2 } ** 5;
1212 var len: usize = 5;
13 _ = &len;
1314 @memcpy(buffer[0..len], buffer[len .. len + 4]);
1415}
1516// run
test/cases/safety/memset_slice_undefined_bytes.zig+1
......@@ -10,6 +10,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1010pub fn main() !void {
1111 var buffer = [6]u8{ 1, 2, 3, 4, 5, 6 };
1212 var len = buffer.len;
13 _ = &len;
1314 @memset(buffer[0..len], undefined);
1415 var x: u8 = buffer[1];
1516 x += buffer[2];
test/cases/safety/memset_slice_undefined_large.zig+1
......@@ -10,6 +10,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1010pub fn main() !void {
1111 var buffer = [6]i32{ 1, 2, 3, 4, 5, 6 };
1212 var len = buffer.len;
13 _ = &len;
1314 @memset(buffer[0..len], undefined);
1415 var x: i32 = buffer[1];
1516 x += buffer[2];
test/cases/safety/optional unwrap operator on C pointer.zig +2-1
......@@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010pub fn main() !void {
1111 var ptr: [*c]i32 = null;
12 var b = ptr.?;
12 _ = &ptr;
13 const b = ptr.?;
1314 _ = b;
1415 return error.TestFailed;
1516}
test/cases/safety/optional unwrap operator on null pointer.zig +2-1
......@@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010pub fn main() !void {
1111 var ptr: ?*i32 = null;
12 var b = ptr.?;
12 _ = &ptr;
13 const b = ptr.?;
1314 _ = b;
1415 return error.TestFailed;
1516}
test/cases/safety/pointer casting null to non-optional pointer.zig +2-1
......@@ -10,7 +10,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1010
1111pub fn main() !void {
1212 var c_ptr: [*c]u8 = 0;
13 var zig_ptr: *u8 = c_ptr;
13 _ = &c_ptr;
14 const zig_ptr: *u8 = c_ptr;
1415 _ = zig_ptr;
1516 return error.TestFailed;
1617}
test/cases/safety/resuming a non-suspended function which has been suspended and resumed.zig +1-1
......@@ -10,7 +10,7 @@ fn foo() void {
1010 global_frame = @frame();
1111 }
1212 var f = async bar(@frame());
13 _ = f;
13 _ = &f;
1414 std.os.exit(1);
1515}
1616
test/cases/safety/resuming a non-suspended function which never been suspended.zig +1-1
......@@ -7,7 +7,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
77}
88fn foo() void {
99 var f = async bar(@frame());
10 _ = f;
10 _ = &f;
1111 std.os.exit(1);
1212}
1313
test/cases/safety/shift left by huge amount.zig +2-1
......@@ -11,7 +11,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1111pub fn main() !void {
1212 var x: u24 = 42;
1313 var y: u5 = 24;
14 var z = x >> y;
14 _ = .{ &x, &y };
15 const z = x >> y;
1516 _ = z;
1617 return error.TestFailed;
1718}
test/cases/safety/shift right by huge amount.zig +2-1
......@@ -11,7 +11,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1111pub fn main() !void {
1212 var x: u24 = 42;
1313 var y: u5 = 24;
14 var z = x << y;
14 _ = .{ &x, &y };
15 const z = x << y;
1516 _ = z;
1617 return error.TestFailed;
1718}
test/cases/safety/signed integer division overflow - vectors.zig +2-2
......@@ -9,8 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010
1111pub fn main() !void {
12 var a: @Vector(4, i16) = [_]i16{ 1, 2, -32768, 4 };
13 var b: @Vector(4, i16) = [_]i16{ 1, 2, -1, 4 };
12 const a: @Vector(4, i16) = [_]i16{ 1, 2, -32768, 4 };
13 const b: @Vector(4, i16) = [_]i16{ 1, 2, -1, 4 };
1414 const x = div(a, b);
1515 if (x[2] == 32767) return error.Whatever;
1616 return error.TestFailed;
test/cases/safety/signed integer not fitting in cast to unsigned integer - widening.zig +2-1
......@@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010pub fn main() !void {
1111 var value: c_short = -1;
12 var casted: u32 = @intCast(value);
12 _ = &value;
13 const casted: u32 = @intCast(value);
1314 _ = casted;
1415 return error.TestFailed;
1516}
test/cases/safety/signed-unsigned vector cast.zig +2-1
......@@ -10,7 +10,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1010
1111pub fn main() !void {
1212 var x: @Vector(4, i32) = @splat(-2147483647);
13 var y: @Vector(4, u32) = @intCast(x);
13 _ = &x;
14 const y: @Vector(4, u32) = @intCast(x);
1415 _ = y;
1516 return error.TestFailed;
1617}
test/cases/safety/slice start index greater than end index.zig +1
......@@ -11,6 +11,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1111pub fn main() !void {
1212 var a: usize = 1;
1313 var b: usize = 10;
14 _ = .{ &a, &b };
1415 var buf: [16]u8 = undefined;
1516
1617 const slice = buf[b..a];
test/cases/safety/slice with sentinel out of bounds - runtime len.zig +1
......@@ -12,6 +12,7 @@ pub fn main() !void {
1212 var buf = [4]u8{ 'a', 'b', 'c', 0 };
1313 const input: []u8 = &buf;
1414 var len: usize = 4;
15 _ = &len;
1516 const slice = input[0..len :0];
1617 _ = slice;
1718 return error.TestFailed;
test/cases/safety/slicing null C pointer - runtime len.zig +2-1
......@@ -11,7 +11,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1111pub fn main() !void {
1212 var ptr: [*c]const u32 = null;
1313 var len: usize = 3;
14 var slice = ptr[0..len];
14 _ = &len;
15 const slice = ptr[0..len];
1516 _ = slice;
1617 return error.TestFailed;
1718}
test/cases/safety/slicing null C pointer.zig +2-1
......@@ -10,7 +10,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1010
1111pub fn main() !void {
1212 var ptr: [*c]const u32 = null;
13 var slice = ptr[0..3];
13 _ = &ptr;
14 const slice = ptr[0..3];
1415 _ = slice;
1516 return error.TestFailed;
1617}
test/cases/safety/truncating vector cast.zig +2-1
......@@ -10,7 +10,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1010
1111pub fn main() !void {
1212 var x: @Vector(4, u32) = @splat(0xdeadbeef);
13 var y: @Vector(4, u16) = @intCast(x);
13 _ = &x;
14 const y: @Vector(4, u16) = @intCast(x);
1415 _ = y;
1516 return error.TestFailed;
1617}
test/cases/safety/unsigned integer not fitting in cast to signed integer - same bit count.zig +2-1
......@@ -9,7 +9,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010pub fn main() !void {
1111 var value: u8 = 245;
12 var casted: i8 = @intCast(value);
12 _ = &value;
13 const casted: i8 = @intCast(value);
1314 _ = casted;
1415 return error.TestFailed;
1516}
test/cases/safety/unsigned-signed vector cast.zig +2-1
......@@ -10,7 +10,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
1010
1111pub fn main() !void {
1212 var x: @Vector(4, u32) = @splat(0x80000000);
13 var y: @Vector(4, i32) = @intCast(x);
13 _ = &x;
14 const y: @Vector(4, i32) = @intCast(x);
1415 _ = y;
1516 return error.TestFailed;
1617}
test/cases/safety/vector integer addition overflow.zig +2-2
......@@ -8,8 +8,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
88 std.process.exit(1);
99}
1010pub fn main() !void {
11 var a: @Vector(4, i32) = [_]i32{ 1, 2, 2147483643, 4 };
12 var b: @Vector(4, i32) = [_]i32{ 5, 6, 7, 8 };
11 const a: @Vector(4, i32) = [_]i32{ 1, 2, 2147483643, 4 };
12 const b: @Vector(4, i32) = [_]i32{ 5, 6, 7, 8 };
1313 const x = add(a, b);
1414 _ = x;
1515 return error.TestFailed;
test/cases/safety/vector integer multiplication overflow.zig +2-2
......@@ -8,8 +8,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
88 std.process.exit(1);
99}
1010pub fn main() !void {
11 var a: @Vector(4, u8) = [_]u8{ 1, 2, 200, 4 };
12 var b: @Vector(4, u8) = [_]u8{ 5, 6, 2, 8 };
11 const a: @Vector(4, u8) = [_]u8{ 1, 2, 200, 4 };
12 const b: @Vector(4, u8) = [_]u8{ 5, 6, 2, 8 };
1313 const x = mul(b, a);
1414 _ = x;
1515 return error.TestFailed;
test/cases/safety/vector integer negation overflow.zig +1
......@@ -9,6 +9,7 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
99}
1010pub fn main() !void {
1111 var a: @Vector(4, i16) = [_]i16{ 1, -32768, 200, 4 };
12 _ = &a;
1213 const x = neg(a);
1314 _ = x;
1415 return error.TestFailed;
test/cases/safety/vector integer subtraction overflow.zig +2-2
......@@ -8,8 +8,8 @@ pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usi
88 std.process.exit(1);
99}
1010pub fn main() !void {
11 var a: @Vector(4, u32) = [_]u32{ 1, 2, 8, 4 };
12 var b: @Vector(4, u32) = [_]u32{ 5, 6, 7, 8 };
11 const a: @Vector(4, u32) = [_]u32{ 1, 2, 8, 4 };
12 const b: @Vector(4, u32) = [_]u32{ 5, 6, 7, 8 };
1313 const x = sub(b, a);
1414 _ = x;
1515 return error.TestFailed;
test/cases/structs.0.zig+1
......@@ -2,6 +2,7 @@ const Example = struct { x: u8 };
22
33pub fn main() u8 {
44 var example: Example = .{ .x = 5 };
5 _ = &example;
56 return example.x - 5;
67}
78
test/cases/structs.2.zig+1
......@@ -2,6 +2,7 @@ const Example = struct { x: u8, y: u8 };
22
33pub fn main() u8 {
44 var example: Example = .{ .x = 5, .y = 10 };
5 _ = &example;
56 return example.y + example.x - 15;
67}
78
test/cases/structs.3.zig+1
......@@ -3,6 +3,7 @@ const Example = struct { x: u8, y: u8 };
33pub fn main() u8 {
44 var example: Example = .{ .x = 5, .y = 10 };
55 var example2: Example = .{ .x = 10, .y = 20 };
6 _ = &example2;
67
78 example = example2;
89 return example.y + example.x - 30;
test/cases/switch.0.zig+2-1
......@@ -1,6 +1,7 @@
11pub fn main() u8 {
22 var val: u8 = 1;
3 var a: u8 = switch (val) {
3 _ = &val;
4 const a: u8 = switch (val) {
45 0, 1 => 2,
56 2 => 3,
67 3 => 4,
test/cases/switch.1.zig+2
......@@ -1,11 +1,13 @@
11pub fn main() u8 {
22 var val: u8 = 2;
3 _ = &val;
34 var a: u8 = switch (val) {
45 0, 1 => 2,
56 2 => 3,
67 3 => 4,
78 else => 5,
89 };
10 _ = &a;
911
1012 return a - 3;
1113}
test/cases/switch.2.zig+2-1
......@@ -1,6 +1,7 @@
11pub fn main() u8 {
22 var val: u8 = 10;
3 var a: u8 = switch (val) {
3 _ = &val;
4 const a: u8 = switch (val) {
45 0, 1 => 2,
56 2 => 3,
67 3 => 4,
test/cases/switch.3.zig+2-1
......@@ -2,7 +2,8 @@ const MyEnum = enum { One, Two, Three };
22
33pub fn main() u8 {
44 var val: MyEnum = .Two;
5 var a: u8 = switch (val) {
5 _ = &val;
6 const a: u8 = switch (val) {
67 .One => 1,
78 .Two => 2,
89 .Three => 3,
test/cases/type_of.0.zig+1
......@@ -1,5 +1,6 @@
11pub fn main() void {
22 var x: usize = 0;
3 _ = &x;
34 const z = @TypeOf(x, @as(u128, 5));
45 assert(z == u128);
56}
test/cases/while_loops.1.zig+1
......@@ -2,6 +2,7 @@ pub fn main() u8 {
22 var i: u8 = 0;
33 while (i < @as(u8, 10)) {
44 var x: u8 = 1;
5 _ = &x;
56 i += x;
67 }
78 return i - 10;
test/cases/while_loops.2.zig+1
......@@ -2,6 +2,7 @@ pub fn main() u8 {
22 var i: u8 = 0;
33 while (i < @as(u8, 10)) {
44 var x: u8 = 1;
5 _ = &x;
56 i += x;
67 if (i == @as(u8, 5)) break;
78 }