diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-03-19 18:06:16 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-19 18:06:16 -0400 |
| commit | dc04e97098010f590d109e6e70d4afe79cd8f01b (patch) | |
| tree | bed11818fd80fe7b4557f4253c8d5562de773624 /test/compile_errors.zig | |
| parent | 555a2c03286507ffe4bd3bea2154dbfb719ebef1 (diff) | |
| parent | 160367e0ddcb36b6957e603d869507b9d7542edc (diff) | |
| download | zig-dc04e97098010f590d109e6e70d4afe79cd8f01b.tar.gz zig-dc04e97098010f590d109e6e70d4afe79cd8f01b.zip | |
Merge pull request #4752 from ziglang/slice-array
slicing with comptime start and end indexes results in pointer-to-array
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index f894a152a7..e3e1462173 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -103,18 +103,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { "tmp.zig:3:23: error: pointer to size 0 type has no address", }); - cases.addTest("slice to pointer conversion mismatch", - \\pub fn bytesAsSlice(bytes: var) [*]align(1) const u16 { - \\ return @ptrCast([*]align(1) const u16, bytes.ptr)[0..1]; - \\} - \\test "bytesAsSlice" { - \\ const bytes = [_]u8{ 0xDE, 0xAD, 0xBE, 0xEF }; - \\ const slice = bytesAsSlice(bytes[0..]); - \\} - , &[_][]const u8{ - "tmp.zig:2:54: error: expected type '[*]align(1) const u16', found '[]align(1) const u16'", - }); - cases.addTest("access invalid @typeInfo decl", \\const A = B; \\test "Crash" { @@ -1918,8 +1906,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { cases.add("reading past end of pointer casted array", \\comptime { \\ const array: [4]u8 = "aoeu".*; - \\ const slice = array[1..]; - \\ const int_ptr = @ptrCast(*const u24, slice.ptr); + \\ const sub_array = array[1..]; + \\ const int_ptr = @ptrCast(*const u24, sub_array); \\ const deref = int_ptr.*; \\} , &[_][]const u8{ |
