[Issue 11853] Tuples fail "isAssignable"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 31 08:17:46 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11853



--- Comment #1 from monarchdodra at gmail.com 2013-12-31 08:17:41 PST ---
According to "dissect", the faulty commit is:
Fix swap for non-assignable:
https://github.com/D-Programming-Language/phobos/commit/97e1fb80d404899cc14d03483f61986791747e38#diff-ff74a46362b5953e8c88120e2490f839

Which added this static test in "swap":
static if (!isAssignable!T || hasElaborateAssign!T)

The bummer is that tuple's opAssign looks like:

        void opAssign(R)(auto ref R rhs)
        if (areCompatibleTuples!(typeof(this), R, "="))
        {
            import std.algorithm : swap;
            swap!(Tuple!Types)(this, rhs);

I'm not quite sure *how* the compiler resolves that:
1. To instantiate opAssign, we need swap...
2. For swap we need to know if assignable...
3. To know if assignable, we need to instantiate opAssign...

In particular, it gives "funny" scenarios such as:

//----
alias T = Tuple!int;

void main()
{
    T t;
    static assert(isAssignable!T); //FAILS
}
//----
alias T = Tuple!int;

void main()
{
    T t;
    t = T.init;
    static assert(isAssignable!T); //PASSES
}
//----

We can workaround the problem by checking "hasElaborateAssign" first, as that
check does not actually look into the implementation. Still, there is some bad
smell here.

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


More information about the Digitalmars-d-bugs mailing list