www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21210] New: std.traits : isAssignable false positive on


          Issue ID: 21210
           Summary: std.traits : isAssignable false positive on disabled
                    copy struct
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

The following code should either compile, or trigger the static assert:
import std.traits;

struct NC {  disable this(this); }

void main ()
    NC a, c;
    static assert(isAssignable!NC);
    c = NC();
    c = a;

Because `isAssignable` definition checks that both lvalues and rvalues can be
However, on the lvalue assignment (`c = a`), the compiler errors out, even
though the `static assert` passed.

Found after https://github.com/dlang/phobos/pull/7609 was reverted.
I believe the reason for this is some aggressive const-folding on the compiler

Aug 30 2020