From 27621cb7207643f914bae7b01902b22a8b5916e7 Mon Sep 17 00:00:00 2001 From: Jimmi Holst Christensen Date: Sat, 14 Feb 2026 18:19:39 +0100 Subject: fix: Add compile error when positional taking many values is not last See https://github.com/Hejsil/zig-clap/issues/153 --- clap.zig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'clap.zig') diff --git a/clap.zig b/clap.zig index 54bcb32..00f195b 100644 --- a/clap.zig +++ b/clap.zig @@ -899,6 +899,24 @@ fn Positionals( if (longest.kind != .positional) continue; + if ((i + 1) != fields_len and param.takes_value == .many) { + @compileError( + \\Only the last positional is allowed to take multiple values + \\This works: + \\ + \\ + \\ ... + \\ + \\This doesn't: + \\ + \\ ... + \\ + \\ + \\See https://github.com/Hejsil/zig-clap/issues/153 + \\ + ); + } + const T = ParamType(Id, param, value_parsers); const FieldT = switch (param.takes_value) { .none => continue, -- cgit v1.2.3