D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 15914 - [REG 2.071] getopt doesn't accept anymore a character for a bool option
Summary: [REG 2.071] getopt doesn't accept anymore a character for a bool option
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-12 06:48 UTC by basile-z
Modified: 2016-06-18 12:31 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description basile-z 2016-04-12 06:48:19 UTC

    
Comment 1 Vladimir Panteleev 2016-04-12 06:54:11 UTC
Please provide a minimum self-contained example.
Comment 2 basile-z 2016-04-12 07:10:56 UTC
Actually even if the option validator is commented, the following test is not compiled


unittest
{
    bool opt;
    string args;
    getopt(args, config.passThrough 'a', &opt);
}�


so the problem comes from somewhere else.

There's nothing in the file history that explicitly remove this feature between 2.070 and 2.071.
Comment 3 basile-z 2016-04-12 07:11:08 UTC
Actually even if the option validator is commented, the following test is not compiled


unittest
{
    bool opt;
    string args;
    getopt(args, config.passThrough 'a', &opt);
}�


so the problem comes from somewhere else.

There's nothing in the file history that explicitly remove this feature between 2.070 and 2.071.
Comment 4 basile-z 2016-04-12 07:13:40 UTC
(In reply to b2.temp from comment #3)
> Actually even if the option validator is commented, the following test is
> not compiled

somment line 626:

static assert(validationMessage == "", validationMessage);

unittest
{
    bool opt;
    string args;
    getopt(args, config.passThrough, 'a', &opt);
}
Comment 5 basile-z 2016-04-12 07:14:21 UTC
I meant "comment" the line
Comment 6 Vladimir Panteleev 2016-04-12 07:15:44 UTC
(In reply to b2.temp from comment #3)
> unittest
> {
>     bool opt;
>     string args;
>     getopt(args, config.passThrough 'a', &opt);
> }

This example never worked.

Even after you add the missing comma and delete the strange character at the end.

Please post an actual complete program that can be copied and pasted into a .d file which will compile with an older version but not a newer one.
Comment 7 Vladimir Panteleev 2016-04-12 07:17:08 UTC
Figured it out. Complete example:

//////////////////// test.d ////////////////////
import std.getopt;

void main()
{
    bool opt;
    string[] args;
    getopt(args, config.passThrough, 'a', &opt);
}
////////////////////////////////////////////////
Comment 8 Vladimir Panteleev 2016-04-12 07:19:10 UTC
Introduced in https://github.com/D-Programming-Language/phobos/pull/3859
Comment 9 github-bugzilla 2016-04-12 07:58:15 UTC
Commit pushed to revert-3859-getopt-checker at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/cedfb8c153b910e2d9e82112b2cbe519cd870491
std.getopt: Add unit test for issue 15914
Comment 10 basile-z 2016-04-12 09:03:28 UTC
If you land here because you're affected by the regression a simple fix consist into replacing the character by a string.

getOpt(args, "a", &a)

A fix is prepared for the next release.
Comment 11 github-bugzilla 2016-04-15 15:23:16 UTC
Commits pushed to stable at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/4a21631a0f35c75b2e22031248245f362c1a021d
fix issue 15914

https://github.com/D-Programming-Language/phobos/commit/def9039f4252df4d17770513e53ee4bdcb20ce61
Merge pull request #4189 from BBasile/issue-15914-stable

fix issue 15914 - [REG 2.071] getopt doesn't accept anymore a character for a bool option