aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorelucent <9532786+elucent@users.noreply.github.com>2020-04-21 02:10:50 -0400
committerAndrew Kelley <andrew@ziglang.org>2020-04-21 18:09:03 -0400
commit48dc3b6fe9e16e9a5dc4b586d260e19bdbd682a1 (patch)
tree48a3251cb7e4e5a3f0aff5d5e827eeddb059c53d /test
parent412aac8a70b2c38cb31f6ab8e76f9fbb774e90bc (diff)
downloadzig-48dc3b6fe9e16e9a5dc4b586d260e19bdbd682a1.tar.gz
zig-48dc3b6fe9e16e9a5dc4b586d260e19bdbd682a1.zip
Added peer type resolution for [*]T and *[N]T.
Diffstat (limited to 'test')
-rw-r--r--test/stage1/behavior/cast.zig19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/stage1/behavior/cast.zig b/test/stage1/behavior/cast.zig
index 7b5f0e8fae..83b21c5379 100644
--- a/test/stage1/behavior/cast.zig
+++ b/test/stage1/behavior/cast.zig
@@ -805,3 +805,22 @@ test "peer type resolve array pointers, one of them const" {
comptime expect(@TypeOf(&array1, &array2) == []const u8);
comptime expect(@TypeOf(&array2, &array1) == []const u8);
}
+
+test "peer type resolve array pointer and unknown pointer" {
+ const const_array: [4]u8 = undefined;
+ var array: [4]u8 = undefined;
+ var const_ptr: [*]const u8 = undefined;
+ var ptr: [*]u8 = undefined;
+
+ comptime expect(@TypeOf(&array, ptr) == [*]u8);
+ comptime expect(@TypeOf(ptr, &array) == [*]u8);
+
+ comptime expect(@TypeOf(&const_array, ptr) == [*]const u8);
+ comptime expect(@TypeOf(ptr, &const_array) == [*]const u8);
+
+ comptime expect(@TypeOf(&array, const_ptr) == [*]const u8);
+ comptime expect(@TypeOf(const_ptr, &array) == [*]const u8);
+
+ comptime expect(@TypeOf(&const_array, const_ptr) == [*]const u8);
+ comptime expect(@TypeOf(const_ptr, &const_array) == [*]const u8);
+}