diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-06-07 22:19:00 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-06-07 22:41:58 -0400 |
| commit | f0b6dac1f2d37ea9eff0116bec34e9b2be9f3ce7 (patch) | |
| tree | cb119ae6c6ce4d1a5022b02a5013e763fdc2aa30 /test | |
| parent | b65203f5736199bdc8d98d27728be5e92a17d565 (diff) | |
| download | zig-f0b6dac1f2d37ea9eff0116bec34e9b2be9f3ce7.tar.gz zig-f0b6dac1f2d37ea9eff0116bec34e9b2be9f3ce7.zip | |
add implicit casts from `*[N]T`
* to `[]T`
* to `[*]T`
See #770
Diffstat (limited to 'test')
| -rw-r--r-- | test/cases/cast.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/cases/cast.zig b/test/cases/cast.zig index 7358a4ffd8..c3ef24cd78 100644 --- a/test/cases/cast.zig +++ b/test/cases/cast.zig @@ -384,3 +384,19 @@ test "const slice widen cast" { assert(@bitCast(u32, bytes) == 0x12121212); } + +test "single-item pointer of array to slice and to unknown length pointer" { + testCastPtrOfArrayToSliceAndPtr(); + comptime testCastPtrOfArrayToSliceAndPtr(); +} + +fn testCastPtrOfArrayToSliceAndPtr() void { + var array = "ao" ++ "eu"; // TODO https://github.com/ziglang/zig/issues/1076 + const x: [*]u8 = &array; + x[0] += 1; + assert(mem.eql(u8, array[0..], "boeu")); + const y: []u8 = &array; + y[0] += 1; + assert(mem.eql(u8, array[0..], "coeu")); +} + |
