implicit casting between C pointer and optional non-C pointer

See #1059
This commit is contained in:
Andrew Kelley
2019-02-12 01:38:11 -05:00
parent 285e2f62ba
commit 6f05e8d1be
2 changed files with 31 additions and 13 deletions
+10
View File
@@ -97,3 +97,13 @@ test "peer type resolution with C pointers" {
expect(@typeOf(x3) == [*c]u8);
expect(@typeOf(x4) == [*c]u8);
}
test "implicit casting between C pointer and optional non-C pointer" {
var slice: []const u8 = "aoeu";
const opt_many_ptr: ?[*]const u8 = slice.ptr;
var ptr_opt_many_ptr = &opt_many_ptr;
var c_ptr: [*c]const [*c]const u8 = ptr_opt_many_ptr;
expect(c_ptr.*.* == 'a');
ptr_opt_many_ptr = c_ptr;
expect(ptr_opt_many_ptr.*.?[1] == 'o');
}