Sema: return const pointers from ref inits

Closes #12189
This commit is contained in:
Veikka Tuominen
2023-05-09 15:30:14 +03:00
parent 0ad692e76c
commit 0a7f8c2e01
2 changed files with 23 additions and 9 deletions

View File

@@ -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);
}