www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10179] New: Tuple assignment should not cause "has no effect" error even if the length is zero

reply d-bugmail puremagic.com writes:
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: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg gmail.com> 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: -------
May 26 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10179


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-05-26 22:34:30 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2084

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10179



--- Comment #2 from github-bugzilla puremagic.com 2013-05-27 06:19:05 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/1a5c0e6f01a78a501782d1f511e0f68d85b36d6f
fix Issue 10179 - Tuple assignment should not cause "has no effect" error even
if the length is zero

https://github.com/D-Programming-Language/dmd/commit/ccfdf10f50e76ae93986619190a542da565388f7
Merge pull request #2084 from 9rnsr/fix10179

[enh] Issue 10179 - Tuple assignment should not cause "has no effect" error
even if the length is zero

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 27 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10179


Andrei Alexandrescu <andrei erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrei erdani.com
         Resolution|                            |FIXED


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