[Issue 21554] New: Invalid assignment expression yields valid type in is(typeof)-expression

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 18 00:09:28 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21554

          Issue ID: 21554
           Summary: Invalid assignment expression yields valid type in
                    is(typeof)-expression
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: kinke at gmx.net

class MyClass
{
    T opCall(T)(T p) { return p; }
}

void emplaceRef(T, Args...)(ref T chunk, auto ref Args args)
{
    static assert(!__traits(compiles, chunk = T(args)));
    // the following fails: `!is(MyClass)` is false
    static assert(!is(typeof(chunk = T(args))));
}

int foo()
{
    MyClass c;
    emplaceRef(c, new MyClass);
}

--


More information about the Digitalmars-d-bugs mailing list