From 2cf27c571880a607401dca181f8103e855d0c46d Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sat, 4 Mar 2023 02:11:04 -0500 Subject: [PATCH 1/3] llvm: fix incorrectly annotated DIType Closes #14715 Closes #14783 --- src/codegen/llvm.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 6f240b88f5..937c1cf120 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1773,7 +1773,7 @@ pub const Object = struct { if (ty.optionalReprIsPayload()) { const ptr_di_ty = try o.lowerDebugType(child_ty, resolve); // The recursive call to `lowerDebugType` means we can't use `gop` anymore. - try o.di_type_map.putContext(gpa, ty, AnnotatedDITypePtr.initFull(ptr_di_ty), .{ .mod = o.module }); + try o.di_type_map.putContext(gpa, ty, AnnotatedDITypePtr.init(ptr_di_ty, resolve), .{ .mod = o.module }); return ptr_di_ty; } From 16302578d5a0ca226c7db76bc8e39574dea1dc1d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 4 Mar 2023 14:04:58 -0700 Subject: [PATCH 2/3] add behavior test case for previous commit --- test/behavior/slice.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/behavior/slice.zig b/test/behavior/slice.zig index 435e1887bb..ed5e2a721d 100644 --- a/test/behavior/slice.zig +++ b/test/behavior/slice.zig @@ -747,3 +747,18 @@ test "slice decays to many pointer" { const p: [*:0]const u8 = buf[0..7 :0]; try expectEqualStrings(buf[0..7], std.mem.span(p)); } + +test "write through pointer to optional slice arg" { + const S = struct { + fn bar(foo: *?[]const u8) !void { + foo.* = try baz(); + } + + fn baz() ![]const u8 { + return "ok"; + } + }; + var foo: ?[]const u8 = null; + try S.bar(&foo); + try expectEqualStrings(foo.?, "ok"); +} From 8ea1c1932e7bd869ec77a161da7876d171d4ef1d Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sun, 5 Mar 2023 04:25:04 -0500 Subject: [PATCH 3/3] behavior: disable failing tests --- test/behavior/slice.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/behavior/slice.zig b/test/behavior/slice.zig index ed5e2a721d..6239de2d76 100644 --- a/test/behavior/slice.zig +++ b/test/behavior/slice.zig @@ -749,6 +749,11 @@ test "slice decays to many pointer" { } test "write through pointer to optional slice arg" { + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + const S = struct { fn bar(foo: *?[]const u8) !void { foo.* = try baz();