From 0a7f8c2e013f24aa6c94093400fe6377ab74b4e1 Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Tue, 9 May 2023 15:30:14 +0300 Subject: Sema: return const pointers from ref inits Closes #12189 --- test/behavior/basic.zig | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/behavior/basic.zig') diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig index 073be26288..5b8ca80198 100644 --- a/test/behavior/basic.zig +++ b/test/behavior/basic.zig @@ -1145,3 +1145,10 @@ test "arrays and vectors with big integers" { try expect(b[0] == comptime std.math.maxInt(Int)); } } + +test "pointer to struct literal with runtime field is constant" { + const S = struct { data: usize }; + var runtime_zero: usize = 0; + const ptr = &S{ .data = runtime_zero }; + try expect(@typeInfo(@TypeOf(ptr)).Pointer.is_const); +} -- cgit v1.2.3