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;
}