aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/array.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2023-04-20 00:55:52 +0100
committerAndrew Kelley <andrew@ziglang.org>2023-04-20 09:05:22 -0700
commitd5f1a8823eb964c6149fc1d627ea6936d70ea7f1 (patch)
tree163967d4c1bac8455b0d3e66734d5788a3f1e6d4 /test/behavior/array.zig
parent31b6d14bf76fa6b78013a6a32d3066e882d64043 (diff)
downloadzig-d5f1a8823eb964c6149fc1d627ea6936d70ea7f1.tar.gz
zig-d5f1a8823eb964c6149fc1d627ea6936d70ea7f1.zip
Sema: allow ptr field access on pointer-to-array
Also remove an incorrect piece of logic which allowed fetching the 'len' property on non-single-ptrs (e.g. many-ptrs) and add a corresponding compile error test case. Resolves: #4765
Diffstat (limited to 'test/behavior/array.zig')
-rw-r--r--test/behavior/array.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/behavior/array.zig b/test/behavior/array.zig
index 88a6ab947d..ec31d4a3fb 100644
--- a/test/behavior/array.zig
+++ b/test/behavior/array.zig
@@ -677,3 +677,13 @@ test "array of array agregate init" {
var b = [1][10]u32{a} ** 2;
try std.testing.expect(b[1][1] == 11);
}
+
+test "pointer to array has ptr field" {
+ const arr: *const [5]u32 = &.{ 10, 20, 30, 40, 50 };
+ try std.testing.expect(arr.ptr == @as([*]const u32, arr));
+ try std.testing.expect(arr.ptr[0] == 10);
+ try std.testing.expect(arr.ptr[1] == 20);
+ try std.testing.expect(arr.ptr[2] == 30);
+ try std.testing.expect(arr.ptr[3] == 40);
+ try std.testing.expect(arr.ptr[4] == 50);
+}