ikskuh / zig-args

Simple-to-use argument parser with struct-based config
MIT License
243 stars 27 forks source link

`parseWithVerbForCurrentProcess` does not work in self-hosted #31

Closed leecannon closed 2 years ago

leecannon commented 2 years ago

When using parseWithVerbForCurrentProcess we hit a compiler TODO:

$ zig build install -fno-stage1
/home/lee/src/zriscv/external/zig-args/args.zig:85:1: error: TODO (LLVM): implement const of pointer type '*(struct decl=Module.Decl.Index(4211))' (value.Value.Tag.u1_type)
fn parseInternal(comptime Generic: type, comptime MaybeVerb: ?type, args_iterator: anytype, allocator: std.mem.Allocator, error_handling: ErrorHandling) !ParseArgsResult(Generic, MaybeVerb) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: zriscv...
error: The step exited with error code 1
error: the following build command failed with exit code 1:
/home/lee/src/zriscv/zig-cache/o/0c3f7ddebe856d7ecddec6a3fdc16368/build /home/lee/src/zig/build/zig /home/lee/src/zriscv /home/lee/src/zriscv/zig-cache /home/lee/.cache/zig install -fno-stage1 -fno-stage1

parseForCurrentProcess seems to work fine.

leecannon commented 2 years ago

Looks like this issue is hit when one of the tags has a zero sized payload

const opt = try args.parseWithVerbForCurrentProcess(struct {}, union(enum) {
    tag: struct {},
}, allocator, .print);
defer opt.deinit();