Skip to content

compilation error with -preview=dip1021 #10738

Open
@nak2yoshi

Description

@nak2yoshi

dmd2.110.0 is ok.
this happen dmd2.111.0 with -preview=dip1021
(Windows11 64bit)

code:

// Bug in dmd2.111.0 with -preview=dip1021.
void main()
{
    // (1)
    {
        import std.range;

        choose(true, cast(const)[1], cast(const)[2]); // Error
        choose(true, [1], [2]); // Error

        chooseAmong(1, cast(const)[1], cast(const)[2]); // Error
        chooseAmong(1, [1], [2]); // Error

        radial(cast(const)[1]); // OK
        radial([1]); // Error

        zip(cast(const)[1], cast(const)[2]); // OK
        zip([1], [2]); // Error

        foreach (i, j; lockstep([1], [2])) // Error
        {
        }

        indexed(cast(const)[1], cast(const)[2]); // OK
        indexed([1], [2]); // Error

        chunks([1], 1); // Error

        assumeSorted([1]); // Error
    }

    // (2)
    {
        import std.regex;

        regex(""); // Error

        enum p = ctRegex!(""); // Error
    }
}

output (1):

C:\Git\sandbox>rdmd -preview=dip1021 bug.d
C:\D\dmd2\windows\bin64\..\..\src\druntime\import\core\lifetime.d(1981): Error: more than one mutable reference to `source` in arguments to `core.lifetime.moveEmplaceImpl!(const(int)[]).moveEmplaceImpl()`
    if (false) moveEmplaceImpl(source, source);
                               ^
C:\D\dmd2\windows\bin64\..\..\src\druntime\import\core\lifetime.d(1925): Error: template instance `core.lifetime.moveImpl!(const(int)[])` error instantiating
    return moveImpl(source);
                   ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(1930):        instantiated from here: `move!(const(int)[])`
        this(cast(size_t)(firstChosen? 0: 1), rs[0].move, rs[1].move);
                                                   ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(1828):        instantiated from here: `ChooseResult!(const(int)[], const(int)[])`
    return ChooseResult!(R1, R2)(choice, r1, r2);
           ^
bug.d(8):        instantiated from here: `choose!(const(int)[], const(int)[])`
        choose(true, cast(const)[1], cast(const)[2]); // Error
              ^
C:\D\dmd2\windows\bin64\..\..\src\druntime\import\core\lifetime.d(1981): Error: more than one mutable reference to `source` in arguments to `core.lifetime.moveEmplaceImpl!(int[]).moveEmplaceImpl()`
    if (false) moveEmplaceImpl(source, source);
                               ^
C:\D\dmd2\windows\bin64\..\..\src\druntime\import\core\lifetime.d(1925): Error: template instance `core.lifetime.moveImpl!(int[])` error instantiating
    return moveImpl(source);
                   ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(1930):        instantiated from here: `move!(int[])`
        this(cast(size_t)(firstChosen? 0: 1), rs[0].move, rs[1].move);
                                                   ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(1828):        instantiated from here: `ChooseResult!(int[], int[])`
    return ChooseResult!(R1, R2)(choice, r1, r2);
           ^
bug.d(9):        instantiated from here: `choose!(int[], int[])`
        choose(true, [1], [2]); // Error
              ^
bug.d(11): Error: template instance `std.range.chooseAmong!(const(int)[], const(int)[])` error instantiating
        chooseAmong(1, cast(const)[1], cast(const)[2]); // Error
                   ^
bug.d(12): Error: template instance `std.range.chooseAmong!(int[], int[])` error instantiating
        chooseAmong(1, [1], [2]); // Error
                   ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(2627): Error: more than one mutable reference of `r` in arguments to `std.range.roundRobin!(Result!(), int[]).roundRobin()`
    return roundRobin(retro(r[0 .. startingIndex]), r[startingIndex .. r.length]);
                           ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(2634): Error: template instance `std.range.radial!(int[], ulong)` error instantiating
    return .radial(r, (r.length - !r.empty) / 2);
                  ^
bug.d(15):        instantiated from here: `radial!(int[])`
        radial([1]); // Error
              ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d-mixin-5556(5556): Error: more than one mutable reference of `this` in arguments to `std.range.ZipShortest!(Flag.yes, int[], int[]).ZipShortest.this()`
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d-mixin-5349(5349): Error: template instance `std.range.ZipShortest!(Flag.yes, int[], int[])` error instantiating
bug.d(18):        instantiated from here: `zip!(int[], int[])`
        zip([1], [2]); // Error
           ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d-mixin-6228(6238): Error: more than one mutable reference of `this` in arguments to `indirectly()`
bug.d(20): Error: template instance `std.range.Lockstep!(int[], int[]).Lockstep.opApplyImpl!(int delegate(ref int, ref int) pure nothrow @nogc @safe)` error instantiating
        foreach (i, j; lockstep([1], [2])) // Error
        ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\algorithm\mutation.d(1288): Error: more than one mutable reference to `source` in arguments to `std.algorithm.mutation.moveEmplaceImpl!(int[]).moveEmplaceImpl()`
    if (false) moveEmplaceImpl(source, source);
                               ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\algorithm\mutation.d(1213): Error: template instance `std.algorithm.mutation.moveImpl!(int[])` error instantiating
    return moveImpl(source);
                   ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(11735):        instantiated from here: `move!(int[])`
        return move(_input);
                   ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(12301):        instantiated from here: `SortedRange!(int[], "a < b", SortedRangeOptions.assumeSorted)`
        return SortedRange!(Unqual!R, pred)(r);
               ^
bug.d(29):        instantiated from here: `assumeSorted!("a < b", int[])`
        assumeSorted([1]); // Error
                    ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(8493): Error: more than one mutable reference of `this` in arguments to `std.range.Indexed!(int[], int[]).Indexed.this()`
            return typeof(this)(_source, _indices.save);
                                ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(8571): Error: more than one mutable reference of `this` in arguments to `std.range.Indexed!(int[], int[]).Indexed.this()`
                return typeof(this)(_source, _indices[a .. b]);
                                    ^
error limit (20) reached, use `-verrors=0` to show all
Failed: ["dmd", "-preview=dip1021", "-v", "-o-", "bug.d", "-I."]

output (2):

C:\Git\sandbox>rdmd -preview=dip1021 bug.d
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\algorithm\mutation.d(1288): Error: more than one mutable reference to `source` in arguments to `std.algorithm.mutation.moveEmplaceImpl!(MapResult!(unaryFun, immutable(UnicodeProperty)[])).moveEmplaceImpl()`
    if (false) moveEmplaceImpl(source, source);
                               ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\algorithm\mutation.d(1213): Error: template instance `std.algorithm.mutation.moveImpl!(MapResult!(unaryFun, immutable(UnicodeProperty)[]))` error instantiating
    return moveImpl(source);
                   ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(11735):        instantiated from here: `move!(MapResult!(unaryFun, immutable(UnicodeProperty)[]))`
        return move(_input);
                   ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(12301):        instantiated from here: `SortedRange!(MapResult!(unaryFun, immutable(UnicodeProperty)[]), __lambda_L5960_C32, SortedRangeOptions.assumeSorted)`
        return SortedRange!(Unqual!R, pred)(r);
               ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\uni\package.d(5961):        instantiated from here: `assumeSorted!((a, b) => propertyNameLess(a, b), MapResult!(unaryFun, immutable(UnicodeProperty)[]))`
        (table.map!"a.name"());
        ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\uni\package.d(6102):        instantiated from here: `findUnicodeSet!(tab, char)`
    return findUnicodeSet!table(name) >= 0;
                               ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\uni\package.d(6936):        instantiated from here: `findSetName!(tab, char)`
            || findSetName!(uniProps.tab)(name) || findSetName!(scripts.tab)(name)
                                         ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(12301): Error: template instance `std.uni.findUnicodeSet!(tab, char).findUnicodeSet.SortedRange!(MapResult!(unaryFun, immutable(UnicodeProperty)[]), __lambda_L5960_C32_1, SortedRangeOptions.assumeSorted)` error instantiating
        return SortedRange!(Unqual!R, pred)(r);
               ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\uni\package.d(5961):        instantiated from here: `assumeSorted!((a, b) => propertyNameLess(a, b), MapResult!(unaryFun, immutable(UnicodeProperty)[]))`
        (table.map!"a.name"());
        ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\uni\package.d(6102):        instantiated from here: `findUnicodeSet!(tab, char)`
    return findUnicodeSet!table(name) >= 0;
                               ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\uni\package.d(6936):        instantiated from here: `findSetName!(tab, char)`
            || findSetName!(uniProps.tab)(name) || findSetName!(scripts.tab)(name)
                                                                            ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\range\package.d(12301): Error: template instance `std.uni.findUnicodeSet!(tab, char).findUnicodeSet.SortedRange!(MapResult!(unaryFun, immutable(UnicodeProperty)[]), __lambda_L5960_C32_2, SortedRangeOptions.assumeSorted)` error instantiating
        return SortedRange!(Unqual!R, pred)(r);
               ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\uni\package.d(5961):        instantiated from here: `assumeSorted!((a, b) => propertyNameLess(a, b), MapResult!(unaryFun, immutable(UnicodeProperty)[]))`
        (table.map!"a.name"());
        ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\uni\package.d(6102):        instantiated from here: `findUnicodeSet!(tab, char)`
    return findUnicodeSet!table(name) >= 0;
                               ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\uni\package.d(6937):        instantiated from here: `findSetName!(tab, char)`
            || (ucmp(name[0 .. 2],"In") == 0 && findSetName!(blocks.tab)(name[2..$]));
                                                                        ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\uni\package.d(6731):        called from here: `findAny("Nd")`
        static if (findAny(name))
                          ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\uni\package.d(6734): Error: static assert:  "No unicode set by name Nd was found."
            static assert(false, "No unicode set by name "~name~" was found.");
            ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\uni\package.d(6441):        instantiated from here: `opDispatch!"Nd"`
                    set.add(unicode.Nd);
                            ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\uni\package.d(6912):        instantiated from here: `UnicodeSetParser!(Parser!(string, CodeGen))`
        auto usParser = UnicodeSetParser!Range(range, casefold);
                        ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\regex\internal\parser.d(900):        instantiated from here: `parseSet!(Parser!(string, CodeGen))`
        g.charsetToIr(unicode.parseSet(this, casefold));
                                      ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\regex\package.d(473):        instantiated from here: `Parser!(string, CodeGen)`
    auto parser = Parser!(Unqual!(typeof(pattern)), CodeGen)(pattern, flags);
                  ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\regex\package.d(421):        instantiated from here: `regexImpl!string`
        return regexImpl(pat, flags);
                        ^
C:\D\dmd2\windows\bin64\..\..\src\phobos\std\regex\package.d(429):        instantiated from here: `regex!(string, immutable(char))`
    return regex([pattern], flags);
                ^
bug.d(36):        instantiated from here: `regex!string`
        regex(""); // Error
             ^
Failed: ["dmd", "-preview=dip1021", "-v", "-o-", "bug.d", "-I."]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions