diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-12-11 16:28:48 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-12-14 14:05:57 +0200 |
| commit | 327fb798c3a2fb18588fc79b1f024cfdd166a4e9 (patch) | |
| tree | 147b55e8e691d28f466f6f3cfe0fd24ac9f5ee98 /test/cases/compile_errors/tuple_ptr_to_mut_slice.zig | |
| parent | 0b4461d97b5d315e71302f96076c54bbdffb7717 (diff) | |
| download | zig-327fb798c3a2fb18588fc79b1f024cfdd166a4e9.tar.gz zig-327fb798c3a2fb18588fc79b1f024cfdd166a4e9.zip | |
move stage2 compile errors out of special folder
Diffstat (limited to 'test/cases/compile_errors/tuple_ptr_to_mut_slice.zig')
| -rw-r--r-- | test/cases/compile_errors/tuple_ptr_to_mut_slice.zig | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/cases/compile_errors/tuple_ptr_to_mut_slice.zig b/test/cases/compile_errors/tuple_ptr_to_mut_slice.zig new file mode 100644 index 0000000000..24e4753563 --- /dev/null +++ b/test/cases/compile_errors/tuple_ptr_to_mut_slice.zig @@ -0,0 +1,32 @@ +export fn entry1() void { + var a = .{ 1, 2, 3 }; + _ = @as([]u8, &a); +} +export fn entry2() void { + var a = .{ @as(u8, 1), @as(u8, 2), @as(u8, 3) }; + _ = @as([]u8, &a); +} + +// runtime values +var vals = [_]u7{ 4, 5, 6 }; +export fn entry3() void { + var a = .{ vals[0], vals[1], vals[2] }; + _ = @as([]u8, &a); +} +export fn entry4() void { + var a = .{ @as(u8, vals[0]), @as(u8, vals[1]), @as(u8, vals[2]) }; + _ = @as([]u8, &a); +} + +// error +// backend=stage2 +// target=native +// +// :3:19: error: cannot cast pointer to tuple to '[]u8' +// :3:19: note: pointers to tuples can only coerce to constant pointers +// :7:19: error: cannot cast pointer to tuple to '[]u8' +// :7:19: note: pointers to tuples can only coerce to constant pointers +// :14:19: error: cannot cast pointer to tuple to '[]u8' +// :14:19: note: pointers to tuples can only coerce to constant pointers +// :18:19: error: cannot cast pointer to tuple to '[]u8' +// :18:19: note: pointers to tuples can only coerce to constant pointers |
