mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
Sema: include sentinel in type of pointer-to-array ptr field
Resolves: #18007
This commit is contained in:
parent
b173088089
commit
673a1efa22
@ -26089,7 +26089,7 @@ fn fieldVal(
|
|||||||
const ptr_info = object_ty.ptrInfo(mod);
|
const ptr_info = object_ty.ptrInfo(mod);
|
||||||
const result_ty = try sema.ptrType(.{
|
const result_ty = try sema.ptrType(.{
|
||||||
.child = ptr_info.child.toType().childType(mod).toIntern(),
|
.child = ptr_info.child.toType().childType(mod).toIntern(),
|
||||||
.sentinel = ptr_info.sentinel,
|
.sentinel = if (inner_ty.sentinel(mod)) |s| s.toIntern() else .none,
|
||||||
.flags = .{
|
.flags = .{
|
||||||
.size = .Many,
|
.size = .Many,
|
||||||
.alignment = ptr_info.flags.alignment,
|
.alignment = ptr_info.flags.alignment,
|
||||||
|
|||||||
@ -74,3 +74,9 @@ test "@src() returns a struct containing 0-terminated string slices" {
|
|||||||
const ptr_src_fn_name: [*:0]const u8 = src.fn_name;
|
const ptr_src_fn_name: [*:0]const u8 = src.fn_name;
|
||||||
_ = ptr_src_fn_name; // unused
|
_ = ptr_src_fn_name; // unused
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "string literal pointer sentinel" {
|
||||||
|
const string_literal = "something";
|
||||||
|
|
||||||
|
try std.testing.expect(@TypeOf(string_literal.ptr) == [*:0]const u8);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user