www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9416] New: [REG][2.060 -> 02.061] DMD eagerly instantiates template parameter-less opAssign

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


--- Comment #0 from monarchdodra gmail.com 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: -------
Jan 28 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9416


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

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


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-01-30 20:19:14 PST ---
https://github.com/D-Programming-Language/dmd/pull/1585

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



--- Comment #2 from github-bugzilla puremagic.com 2013-01-31 01:47:30 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/ca03c609211952f9640d38531dd4f282cedc22ac
fix Issue 9416 - [REG][2.060 -> 02.061] DMD eagerly instantiates template
parameter-less opAssign

https://github.com/D-Programming-Language/dmd/commit/b94fd3b7d2164ef1fc924265d4c5d04c7c673463
Merge pull request #1585 from 9rnsr/fix_assign

Issue 9258 & 9404 & 9416 - fix regressions around opAssign

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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