Thread overview
[Issue 10956] std.getopt error on wrongly position arguments should improve
Nov 27, 2015
bb.temp@gmx.com
Dec 01, 2015
bb.temp@gmx.com
Dec 06, 2015
bb.temp@gmx.com
Feb 18, 2016
b2.temp@gmx.com
Mar 21, 2020
Basile-z
November 27, 2015
https://issues.dlang.org/show_bug.cgi?id=10956

bb.temp@gmx.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bb.temp@gmx.com

--- Comment #1 from bb.temp@gmx.com ---
diagnostic has changed but still bad.

The variadic args in getoptImpl
December 01, 2015
https://issues.dlang.org/show_bug.cgi?id=10956

--- Comment #2 from bb.temp@gmx.com ---
(In reply to Andrej Mitrovic from comment #0)
> -----
> import std.getopt;
> 
> void main(string[] args)
> {
>     int i;
>     getopt(args, &i, "");
> }
> -----
> 
> This call is wrong, the text argument should come before the pointer, but the diagnostics are bad:
> 
> std\getopt.d(499): Deprecation: using * on an array is deprecated; use
> *(receiver).ptr instead
> std\getopt.d(499): Error: cannot modify immutable expression
> *cast(immutable(char)*)receiver
> std\getopt.d(500): Deprecation: using * on an array is deprecated; use
> *(receiver).ptr instead
> std\getopt.d(500): Deprecation: using * on an array is deprecated; use
> *(receiver).ptr instead
> std\getopt.d(500): Error: cannot modify immutable expression
> *cast(immutable(char)*)receiver
> std\getopt.d(400): Error: template instance std.getopt.handleOption!string
> error instantiating
> std\getopt.d(351):        instantiated from here: getoptImpl!(int*, string)
> test.d(8):        instantiated from here: getopt!(int*, string)
> std\getopt.d(351): Error: template instance std.getopt.getoptImpl!(int*,
> string) error instantiating
> test.d(8):        instantiated from here: getopt!(int*, string)
> test.d(8): Error: template instance std.getopt.getopt!(int*, string) error
> instantiating

I'll probably propose something in the next weeks. I've currently designed a template that works in the constraint, however it misses a special case (option passed for next param):

http://dpaste.dzfl.pl/b8d1fb991482

Anyway, quite faisable...

--
December 06, 2015
https://issues.dlang.org/show_bug.cgi?id=10956

--- Comment #3 from bb.temp@gmx.com ---
(In reply to bb.temp from comment #2)
> (In reply to Andrej Mitrovic from comment #0)
> > -----
> Anyway, quite faisable...

done:

https://github.com/BBasile/phobos/blob/ce4c33ed68ae7a1131a5b45c1ddae47c1f391d5c/std/getopt.d#L537-L610

http://dpaste.dzfl.pl/85c70ecd3ddd

all the existing unittests pass.

--
February 18, 2016
https://issues.dlang.org/show_bug.cgi?id=10956

b2.temp@gmx.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from b2.temp@gmx.com ---
closed by

https://github.com/D-Programming-Language/phobos/pull/3859

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=10956

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--