diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-20 12:24:51 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-20 12:24:51 -0400 |
| commit | 9c8dfadbb1b95703a1503ae3a508f5acc29e7695 (patch) | |
| tree | e5884cb00c039385d68b1153a130cd6df0f80b77 /test/compile_errors.zig | |
| parent | f8fe517d126d582e37ab4537fe9fd42f0531f44b (diff) | |
| download | zig-9c8dfadbb1b95703a1503ae3a508f5acc29e7695.tar.gz zig-9c8dfadbb1b95703a1503ae3a508f5acc29e7695.zip | |
add compile error for casting const array to mutable slice
See #1565
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 0b1446b518..dfe17e9d82 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,16 @@ const tests = @import("tests.zig"); pub fn addCases(cases: *tests.CompileErrorContext) void { cases.add( + "implicit cast const array to mutable slice", + \\export fn entry() void { + \\ const buffer: [1]u8 = []u8{8}; + \\ const sliceA: []u8 = &buffer; + \\} + , + ".tmp_source.zig:3:27: error: expected type '[]u8', found '*const [1]u8'", + ); + + cases.add( "deref slice and get len field", \\export fn entry() void { \\ var a: []u8 = undefined; |
