| ... | ... | @@ -747,3 +747,18 @@ test "slice decays to many pointer" { |
| 747 | 747 | const p: [*:0]const u8 = buf[0..7 :0]; |
| 748 | 748 | try expectEqualStrings(buf[0..7], std.mem.span(p)); |
| 749 | 749 | } |
| 750 | |
| 751 | test "write through pointer to optional slice arg" { |
| 752 | const S = struct { |
| 753 | fn bar(foo: *?[]const u8) !void { |
| 754 | foo.* = try baz(); |
| 755 | } |
| 756 | |
| 757 | fn baz() ![]const u8 { |
| 758 | return "ok"; |
| 759 | } |
| 760 | }; |
| 761 | var foo: ?[]const u8 = null; |
| 762 | try S.bar(&foo); |
| 763 | try expectEqualStrings(foo.?, "ok"); |
| 764 | } |