Skip to content

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

@kinke

Description

@kinke
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Severity:RegressionIssues that are regressions/PRs that fix regressions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions