opCall override default constructor?

Marc Schütz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 2 03:16:40 PDT 2016


On Thursday, 2 June 2016 at 08:50:26 UTC, Jacob Carlborg wrote:
> Is it intentional that a non-static opCall overrides the 
> default constructor of a struct?
>
> struct Foo
> {
>     int a;
>
>     void opCall(string b) { }
> }
>
> void main()
> {
>     auto f = Foo(3); // line 14
>     f("asd");
> }
>
> The above code gives the following error:
>
> main.d(14): Error: function main.Foo.opCall (string b) is not 
> callable using argument types (int)

It's this bug:
https://issues.dlang.org/show_bug.cgi?id=9078


More information about the Digitalmars-d-learn mailing list