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

           Summary: [REG][2.060 -> 02.061] DMD eagerly instantiates
                    template parameter-less opAssign
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from [email protected] 2013-01-28 05:48:01 PST ---
Regression from 2.060:

No matter what, when given an template but parameter less opAssign that takes a
typeof(this) (or a type explicitly castable to typeof(this)), dmd will try to
instantiate it.

Here is a clearer explanation in the form of a reduced test case.

//----
struct S
{
    void bar()(S)
    {
        static assert(0); //Fine
    }
    void opAssign()(int)
    {
        static assert(0); //Fine
    }
    void opAssign()(S)
    {
        static assert(0);
            //main.d(13): Error: static assert  (0) is false
            //main.d(2):        instantiated from here: opAssign!()
    }
}

void main()
{}
//----

Expected behavior should be: No error unless opAssign is called (It isn't).

This is problematic for template structs that use this scheme for "poor man's
SFINAE", or who template functions just so that the compiler can guess the
correct "nothrowness" of said function.

For example: std.typecons.Nullable:

//----
import std.typecons;

void main()
{
    Nullable!(immutable int) s;
}
//----

2.060: Fine
2.061: src\phobos\std\typecons.d(1170): Error: can only initialize const member
_value inside constructor

//Inside std.typecons.Nullable:
    void opAssign()(T value)
    {
        _value = value;  //HERE
        _isNull = false;
    }

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

Reply via email to