[Issue 20819] New: std.getopt should detect duplicated pointers passed as arguments.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 11 04:03:07 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20819

          Issue ID: 20819
           Summary: std.getopt should detect duplicated pointers passed as
                    arguments.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: witold.baryluk+d at gmail.com

import std.getop;

    auto optparser = getopt(
      args,
      std.getopt.config.passThrough,
      std.getopt.config.caseSensitive,
      ....,
      "iterations_min",       "A iterations minimum (default: " ~
to!string(iterations_min) ~ ")", &iterations_min,
      "iterations_max",       "A iterations maximum (default: " ~
to!string(iterations_max) ~ ")", &iterations_min,
    );



Spot the error.

It should be detected by the getopt automatically and throw an exception
without even checking the 'args'. I really doubt there is a valid use case to
have duplicated pointers, and if there is (i.e. renaming flags and deprecating
but supporting old one), it can be enabled using std.getopt.config flag.

--


More information about the Digitalmars-d-bugs mailing list