Thread overview
opCall override default constructor?
Jun 02, 2016
Jacob Carlborg
Jun 02, 2016
Era Scarecrow
Jun 02, 2016
Marc Schütz
Jun 02, 2016
Jacob Carlborg
June 02, 2016
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)

-- 
/Jacob Carlborg
June 02, 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?
>
>     auto f = Foo(3); // line 14
>
> main.d(14): Error: function main.Foo.opCall (string b) is not callable using argument types (int)

 It sounds like a bug, since the object isn't instantiated yet it shouldn't be able to call opCall yet...
June 02, 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
June 02, 2016
On 2016-06-02 12:16, Marc Schütz wrote:

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

Ok, thanks.

-- 
/Jacob Carlborg