aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-03-19 18:06:16 -0400
committerGitHub <noreply@github.com>2020-03-19 18:06:16 -0400
commitdc04e97098010f590d109e6e70d4afe79cd8f01b (patch)
treebed11818fd80fe7b4557f4253c8d5562de773624 /test/compile_errors.zig
parent555a2c03286507ffe4bd3bea2154dbfb719ebef1 (diff)
parent160367e0ddcb36b6957e603d869507b9d7542edc (diff)
downloadzig-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.zig16
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{