[Issue 4103] New: opAssign signature rules not enforced on templated opAssign

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 19 00:59:12 PDT 2010


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

           Summary: opAssign signature rules not enforced on templated
                    opAssign
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bugzilla at kyllingen.net


--- Comment #0 from Lars T. Kyllingstad <bugzilla at kyllingen.net> 2010-04-19 00:59:09 PDT ---
The "Operator Overloading" page of the spec says that:

   "...the following parameter signatures for opAssign
    are not allowed:
    ...
    opAssign(T)
    ...
    where T is the same type as the aggregate type A..."


However, the following compiles:

    import std.stdio;

    struct S
    {
        S opAssign(T)(T t)
        {
            writeln(T.stringof);
            return this;
        }
    }

    void main()
    {
        S a, b;
        a = b;
    }

When run, it prints 'S'.

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


More information about the Digitalmars-d-bugs mailing list