| author | |
| committer | |
| log | 73c857415eafc1d0856b6917cada94d8acde41e0 |
| tree | 7278b0ccd1a7b0d74ff84c701238a72fd563bdd6 |
| parent | c1f71963a9b8c913acee0fc167e0a4ecdecd2890 |
2 files changed, 9 insertions(+), 1 deletions(-)
lib/std/json.zig+1-1| ... | ... | @@ -1639,7 +1639,7 @@ fn parseInternal( |
| 1639 | 1639 | const allocator = options.allocator orelse return error.AllocatorRequired; |
| 1640 | 1640 | switch (ptrInfo.size) { |
| 1641 | 1641 | .One => { |
| 1642 | const r: T = try allocator.create(ptrInfo.child); | |
| 1642 | const r: *ptrInfo.child = try allocator.create(ptrInfo.child); | |
| 1643 | 1643 | errdefer allocator.destroy(r); |
| 1644 | 1644 | r.* = try parseInternal(ptrInfo.child, token, tokens, options); |
| 1645 | 1645 | return r; |
lib/std/json/test.zig+8| ... | ... | @@ -2238,6 +2238,14 @@ test "parse into struct with no fields" { |
| 2238 | 2238 | try testing.expectEqual(T{}, try parse(T, &ts, ParseOptions{})); |
| 2239 | 2239 | } |
| 2240 | 2240 | |
| 2241 | const test_const_value: usize = 123; | |
| 2242 | ||
| 2243 | test "parse into struct with default const pointer field" { | |
| 2244 | const T = struct { a: *const usize = &test_const_value }; | |
| 2245 | var ts = TokenStream.init("{}"); | |
| 2246 | try testing.expectEqual(T{}, try parse(T, &ts, .{})); | |
| 2247 | } | |
| 2248 | ||
| 2241 | 2249 | test "parse into struct where destination and source lengths mismatch" { |
| 2242 | 2250 | const T = struct { a: [2]u8 }; |
| 2243 | 2251 | var ts = TokenStream.init("{\"a\": \"bbb\"}"); |