http://d.puremagic.com/issues/show_bug.cgi?id=10179

           Summary: Tuple assignment should not cause "has no effect"
                    error even if the length is zero
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Kenji Hara <[email protected]> 2013-05-26 20:35:32 PDT ---
Currently zero-length tuple assignment would cause "has no effect" error.

struct S {}

void main()
{
    S s;
    static assert(s.tupleof.length == 0);
    s.tupleof = s.tupleof;   // error
}

This is basically not bad, but in generic code this behavior requires
additional length check.

struct S(Types...)
{
    Types field;

    void set(S rhs)
    {
        //field = rhs.field;
        // --> When Types.length == 0, "has no effect" error occurs.

        // Workaround
        static if (Types.length > 0)    // additional check
            field = rhs.field;
    }
}
void main()
{

    S!(int, long) s1;
    s1.set(s1);

    S!() s2;
    s2.set(s2);
}

So I think that stop reporting "has no effect" error for tuple assignment is
small but useful improvement.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to