Bug 8677 – compiler attempts to call ctor instead of opCall
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-09-17T07:31:00Z
Last change time
2012-09-17T10:49:43Z
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2012-09-17T07:31:40Z
struct Foo
{
this(int) {}
bool opCall(string)
{
return true;
}
}
void main()
{
Foo foo = Foo(1);
if (foo("a")) { } // error
}
test.d(17): Error: constructor test.Foo.this (int _param_0) is not callable using argument types (string)
test.d(17): Error: cannot implicitly convert expression ("a") of type string to int
The compiler has no business calling a ctor on a variable invocation.
Comment #1 by bearophile_hugs — 2012-09-17T09:40:48Z
Probably this is a dupe.
Comment #2 by andrej.mitrovich — 2012-09-17T10:49:43Z