Bug 2958 – std.getopt RangeError on missing arg

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2009-05-10T01:19:00Z
Last change time
2015-06-09T01:27:58Z
Assigned to
andrei
Creator
bugs-d

Comments

Comment #0 by bugs-d — 2009-05-10T01:19:50Z
Currently, using std.getopt will result in a RangeError if parameters are improperly omitted on the command line. Since this is a reasonable user-error, it does not seem like something to crash on during release. The problem is here: if (!isDelegateWithLessThanTwoParameters && !val && !incremental) { // eat the next argument too val = args[i]; args = args[0 .. i] ~ args[i + 1 .. $]; } It just needs a check to see if args.length is high enough for this to happen. And the documentation should note the exception it throws; currently it says only a ConvError is thrown. -[Unknown]
Comment #1 by dsimcha — 2010-08-20T17:20:16Z