Skip to content
This repository was archived by the owner on Feb 14, 2024. It is now read-only.

??T on bare struct causes compile error #11

@haze

Description

@haze
pub const Document = struct {
    revision: ??[]const u8,
    description: ??[]const u8,
};

parsing the preceding results in this compile error:

/Users/haze/.cache/zig/p/1220beaae8d152baa941a10b7ef3d3a59d093b257047035e2373c3c2f876ad29ccc8/tres.zig:549:69: error: unable to evaluate comptime expression
                    } else if (comptime dualable(field.type) and nm == .dual) {
                                                                 ~~~^~~~~~~~
/Users/haze/.cache/zig/p/1220beaae8d152baa941a10b7ef3d3a59d093b257047035e2373c3c2f876ad29ccc8/tres.zig:549:66: note: operation is runtime due to this operand
                    } else if (comptime dualable(field.type) and nm == .dual) {

(parsed like so)

    var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
    defer arena.deinit();

    var parser = std.json.Parser.init(arena.allocator(), false);
    const tree = try parser.parse(data);

    const document = try tres.parse(Document, tree.root, arena.allocator());
    std.log.warn("{}", .{document});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions