digitalmars.D.bugs - [Issue 20589] New: typeof may give wrong result in case of classes
- d-bugmail puremagic.com (39/39) Feb 20 2020 https://issues.dlang.org/show_bug.cgi?id=20589
https://issues.dlang.org/show_bug.cgi?id=20589 Issue ID: 20589 Summary: typeof may give wrong result in case of classes defining `opCall` operator Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: drug2004 bk.ru ``` import std; class AClass { T opCall(T)(T p) { return p; } } void main(){ Array!AClass arr; } ``` compiles with error ``` ... phobos/std/conv.d(4434): Error: need this for opCall of type pure nothrow nogc safe AClass(AClass p) ``` The reason is that in std.conv.emplaceRef ``` static if (is(typeof(chunk = T(args)))) chunk = T(args); ``` `is(typeof(chunk = T(args)))` return true but the expression `chunk = T(args);` do not compiles nevertheless. --
Feb 20 2020