www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12904] New: Wrong-code for some slice to slice assignments

https://issues.dlang.org/show_bug.cgi?id=12904

          Issue ID: 12904
           Summary: Wrong-code for some slice to slice assignments when
                    using `opDollar`
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: wrong-code
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: verylonglogin.reg gmail.com

This code should run fine:
---
struct S
{
    size_t opDollar(size_t dim)() // never called but should
    { return 7; }

    int opSlice(size_t dim)(size_t, size_t to)
    {
        assert(to == 7); // fails
        return 1;
    }

    int opIndex(int, int)
    {
        return 1;
    }

    void opSliceAssign(int)
    { }

    // This functions existence prevents `opDollar` from being called:
    void opIndexAssign(U, A...)(U value, A args)
    {
        static assert(0);
    }
}

void main()
{
    S s;
    // `s[0..$, 0..$]` causes ICE Issue 12902
    s[] = s[0..$, 1];
}
---

Probably has the same root as Issue 12902.

--
Jun 13 2014