Thread overview | ||||||
---|---|---|---|---|---|---|
|
June 02, 2016 opCall override default constructor? | ||||
---|---|---|---|---|
| ||||
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 Re: opCall override default constructor? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | 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 Re: opCall override default constructor? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | 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 Re: opCall override default constructor? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marc Schütz | 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 |
Copyright © 1999-2021 by the D Language Foundation