[Issue 20589] New: typeof may give wrong result in case of classes defining `opCall` operator
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 20 09:55:48 UTC 2020
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 at puremagic.com
Reporter: drug2004 at 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.
--
More information about the Digitalmars-d-bugs
mailing list