| ... | ... | @@ -27,8 +27,7 @@ pub fn parse(alloc: std.mem.Allocator, path: string, inreader: anytype, options: |
| 27 | 27 | std.debug.assert(try p.addArray(alloc, &.{}) == .empty_array); |
| 28 | 28 | std.debug.assert(try p.addObject(alloc, &ObjectHashMap{}) == .empty_object); |
| 29 | 29 | |
| 30 | | const root_err: (@TypeOf(inreader).Error || Error)!ValueIndex = @errorCast(parseElement(alloc, &p)); |
| 31 | | const root = try root_err; |
| 30 | const root = try parseElementPrecise(alloc, &p, @TypeOf(inreader).Error || Error); |
| 32 | 31 | if (p.avail() > 0) return error.MalformedJson; |
| 33 | 32 | const data = try p.parser.data.toOwnedSlice(alloc); |
| 34 | 33 | |
| ... | ... | @@ -38,6 +37,10 @@ pub fn parse(alloc: std.mem.Allocator, path: string, inreader: anytype, options: |
| 38 | 37 | }; |
| 39 | 38 | } |
| 40 | 39 | |
| 40 | fn parseElementPrecise(alloc: std.mem.Allocator, p: *Parser, comptime E: type) E!ValueIndex { |
| 41 | return @errorCast(parseElement(alloc, p)); |
| 42 | } |
| 43 | |
| 41 | 44 | fn parseElement(alloc: std.mem.Allocator, p: *Parser) anyerror!ValueIndex { |
| 42 | 45 | const t = tracer.trace(@src(), "", .{}); |
| 43 | 46 | defer t.end(); |