fix regression in zig run runtime arguments

This brings back #10950, which was reverted in 5ab5e2e6731a9f1198df6c53134545ccc6a6bbd3
because it [introduced a regression in `zig run`](https://github.com/ziglang/zig/pull/10950#issuecomment-1049481212)
where the runtime arguments passed were incorrect.

I've fixed the issue, and notably this was the only location where we
directly relied on accessing arguments by index in this code still (all
other locations use the iterator proper) and so we should be all good to
go now.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-03-05 15:23:08 -07:00
parent cfb4f48941
commit c3a2b51a2c

View File

@ -799,9 +799,9 @@ fn buildOutputType(
return cleanExit();
} else if (mem.eql(u8, arg, "--")) {
if (arg_mode == .run) {
// The index refers to all_args so skip `zig` `run`
// and `--`
runtime_args_start = args_iter.i + 3;
// args_iter.i is 1, referring the next arg after "--" in ["--", ...]
// Add +2 to the index so it is relative to all_args
runtime_args_start = args_iter.i + 2;
break :args_loop;
} else {
fatal("unexpected end-of-parameter mark: --", .{});