28460, "jabraham17", "[Bug]: Argument parser doesn't error about unknown flag names", "2026-02-26T18:42:05Z"
The following code demonstrates the issue
use ArgumentParser;
proc main(args: [] string) {
var parser = new argumentParser();
var fooFlag = parser.addFlag(name="foo", defaultValue=false);
var arg = parser.addArgument(name="x", numArgs=1);
parser.parseArgs(args);
writeln("foo is ", fooFlag.valueAsBool());
writeln("arg is ", arg.value());
}
If I compile and run this code, I should be required to provide a positional argument
./myApp
x Required value missing
If I provide the positional argument and an unknown flag, I get the proper error
./myApp x --bar
Found some unrecognizable arguments: --bar
But if I just pass an unknown flag, I get no error
./myApp --bar
foo is false
arg is --bar
The same behavior occurs with optional arguments specified as numArgs=0..1 or multiple arguments like numArgs=2 or numArgs=0..2