#parseFromTokenSource during comptime

1 messages · Page 1 of 1 (latest)

light hawk
#

Trying to comptime but compiler is complaining about runtime allocator from parseFromTokenSource even if I pass it a FixedBufferAllocator

/home/v/sand/zig-linux-x86_64-0.14.0-dev.2625+23281704d/lib/std/mem.zig:3923:18: error: unable to evaluate comptime expression
    const addr = @intFromPtr(ptr);
                 ^~~~~~~~~~~~~~~~
/home/v/sand/zig-linux-x86_64-0.14.0-dev.2625+23281704d/lib/std/mem.zig:3923:30: note: operation is runtime due to this operand
    const addr = @intFromPtr(ptr);
#

I think it's because I was creating my fba at runtime rather than at the top of file

#

hrmm, removed runtime stuff and still erroring but at least in new location

/home/v/sand/zig-linux-x86_64-0.14.0-dev.2625+23281704d/lib/std/heap.zig:430:62: error: unable to evaluate comptime expression
        const adjust_off = mem.alignPointerOffset(self.buffer.ptr + self.end_index, ptr_align) orelse return null;
                                                  ~~~~~~~~~~~^~~~
/home/v/sand/zig-linux-x86_64-0.14.0-dev.2625+23281704d/lib/std/mem/Allocator.zig:86:29: note: called at comptime from here
    return self.vtable.alloc(self.ptr, len, ptr_align, ret_addr);
#

now I'm just throwing "comptime" on everything and got

src/lexicon.zig:124:57: error: unable to resolve comptime value
    comptime var reader = std.json.reader(fba_alloc, fbs.reader());
                                                     ~~~^~~~~~~
src/lexicon.zig:124:42: note: 'comptime' keyword forces comptime evaluation
    comptime var reader = std.json.reader(fba_alloc, fbs.reader());

so maybe it's a fixedbufferstream thing?

young pasture
#

(and that issue in general)

light hawk
#

interesting ... I'm assuming then the issue is that std.json.parseFromTokenSourceLeaky(std.json.Value, fba_alloc, &reader, .{}); allocates something with an ill-defined layout