Commit 673a1efa22
Changed files (2)
src
test
behavior
src/Sema.zig
@@ -26089,7 +26089,7 @@ fn fieldVal(
const ptr_info = object_ty.ptrInfo(mod);
const result_ty = try sema.ptrType(.{
.child = ptr_info.child.toType().childType(mod).toIntern(),
- .sentinel = ptr_info.sentinel,
+ .sentinel = if (inner_ty.sentinel(mod)) |s| s.toIntern() else .none,
.flags = .{
.size = .Many,
.alignment = ptr_info.flags.alignment,
test/behavior/string_literals.zig
@@ -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;
_ = 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);
+}