Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REG2.111] std.getopt doesn't accept const(string)[] anymore #10680

Closed
kinke opened this issue Mar 17, 2025 · 1 comment
Closed

[REG2.111] std.getopt doesn't accept const(string)[] anymore #10680

kinke opened this issue Mar 17, 2025 · 1 comment
Labels
Severity:Regression Issues that are regressions/PRs that fix regressions

Comments

@kinke
Copy link
Contributor

kinke commented Mar 17, 2025

void main() {
    import std.getopt;

    const(string)[] s;
    string[] args;
    getopt(args, "-s", &s);
}

This compiles fine with DMD/Phobos v2.110.0, but doesn't compile with v2.111.0-beta.1:

/home/mkinkelin/dlang/dmd-2.111.0-beta.1/linux/bin64/../../src/phobos/std/getopt.d(620): Error: cannot modify `const` expression `*receiver`
        *receiver = to!(typeof(*receiver))(value);
        ^
/home/mkinkelin/dlang/dmd-2.111.0-beta.1/linux/bin64/../../src/phobos/std/getopt.d(964): Error: template instance `std.getopt.handleConversion!(const(string))` error instantiating
                    handleConversion(option, val, &tmp, i);
                                    ^
/home/mkinkelin/dlang/dmd-2.111.0-beta.1/linux/bin64/../../src/phobos/std/getopt.d(772):        instantiated from here: `handleOption!(const(string)[]*)`
            bool optWasHandled = handleOption(option, receiver, args, cfg, incremental);
                                             ^
/home/mkinkelin/dlang/dmd-2.111.0-beta.1/linux/bin64/../../src/phobos/std/getopt.d(430):        instantiated from here: `getoptImpl!(string, const(string)[]*)`
    getoptImpl(args, cfg, rslt, excep, visitedLongOpts, visitedShortOpts, opts);
              ^
getopt_bug.d(6):        instantiated from here: `getopt!(string, const(string)[]*)`
    getopt(args, "-s", &s);
          ^

Introduced in #10593.

@kinke kinke added the Severity:Regression Issues that are regressions/PRs that fix regressions label Mar 17, 2025
@kinke kinke changed the title [REG2.111] std.getopt doesn't accept const(string][] anymore [REG2.111] std.getopt doesn't accept const(string)[] anymore Mar 17, 2025
schveiguy added a commit to schveiguy/phobos that referenced this issue Mar 17, 2025
…ction,

just return the value and assign it to the receiver. Renamed the
conversion function and also cleaned up all the `typeof` calls, which
were very verbose.
thewilsonator pushed a commit that referenced this issue Mar 17, 2025
#10684)

just return the value and assign it to the receiver. Renamed the
conversion function and also cleaned up all the `typeof` calls, which
were very verbose.
@kinke
Copy link
Contributor Author

kinke commented Mar 17, 2025

Fixed by #10684.

@kinke kinke closed this as completed Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Severity:Regression Issues that are regressions/PRs that fix regressions
Projects
None yet
Development

No branches or pull requests

1 participant