Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 1905

Show
Ignore:
Timestamp:
08/21/10 00:19:57 (14 years ago)
Author:
dsimcha
Message:

Bug 2958: std.getopt RangeError? on missing arg

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/docsrc/changelog.dd

    r1901 r1905  
    1515    $(LI std.typetuple:  Added anySatisfy.)  
    1616    ) 
    1717    $(BUGSFIXED 
    1818    $(LI Unlisted Bug:  std.math.pow doesn't work on immutable numbers.) 
    1919    $(LI Unlisted Bug:  std.math.pow floating point overload expects both arguments to be exact same type.) 
    2020    $(LI Unlisted Bug:  std.path.join("", "foo") returns "/foo" instead of "foo" on Posix.) 
    2121    $(LI Unlisted Bug:  std.range.iota() random access primitives inconsistent after popFront on floating point version) 
    2222    $(LI Several unlisted bugs in std.range.chain) 
    2323    $(LI $(BUGZILLA 2903): Splitter should be bi-dir if the input range is bi-dir.) 
    2424    $(LI $(BUGZILLA 2951): std.random.dice() should be templated on proportions.) 
     25    $(LI $(BUGZILLA 2958): std.getopt RangeError on missing arg) 
    2526    $(LI $(BUGZILLA 3123): std.algorithm.zip fails on 'lazy' ranges) 
    2627    $(LI $(BUGZILLA 3294): forward reference to inferred return type of function call) 
    2728    $(LI $(BUGZILLA 3312): std.string.count should use const(char)[], not immutable.) 
    2829    $(LI $(BUGZILLA 3348): Documentation for many std.process functions has disappeared) 
    2930    $(LI $(BUGZILLA 3361): code in std.zlib concatenates void[] arrays ) 
    3031    $(LI $(BUGZILLA 3877): std.range.chain do not manage infinite ranges correctly) 
    3132    $(LI $(BUGZILLA 3894): std.range.Stride!R requires R.front() and R.back() to return by reference) 
    3233    $(LI $(BUGZILLA 3946): schwartzSort - SwapStrategy always unstable) 
    3334    $(LI $(BUGZILLA 4402): std.range.Zip doesn't work w/ non-lvalue ranges.) 
    3435    $(LI $(BUGZILLA 4408): Ambiguity when using std.algorithm.splitter with generic ranges.) 
  • trunk/phobos/std/getopt.d

    r1822 r1905  
    421421        static if (is(typeof(*receiver) == bool)) { 
    422422            *receiver = true; 
    423423            break; 
    424424        } else { 
    425425            // non-boolean option, which might include an argument 
    426426            //enum isDelegateWithOneParameter = is(typeof(receiver("")) : void); 
    427427            enum isDelegateWithLessThanTwoParameters = 
    428428                is(typeof(receiver) == delegate) && 
    429429                !is(typeof(receiver("", ""))); 
    430430            if (!isDelegateWithLessThanTwoParameters && !val && !incremental) { 
    431                 // eat the next argument too 
     431                // Eat the next argument too.  Check to make sure there's one 
     432                // to be eaten first, though. 
     433                enforce(i < args.length, 
     434                    "Missing value for argument " ~ a ~ "."); 
    432435                val = args[i]; 
    433436                args = args[0 .. i] ~ args[i + 1 .. $]; 
    434437            } 
    435438            static if (is(typeof(*receiver) : real)) 
    436439            { 
    437440                // numeric receiver 
    438441                if (incremental) ++*receiver; 
    439442                else *receiver = to!(typeof(*receiver))(val); 
    440443            } 
    441444            else static if (is(typeof(*receiver) == string))