Cannot instantiate a std.container.Array of a class with a init() function member.
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Mon Mar 2 09:48:05 PST 2015
On Mon, Mar 02, 2015 at 04:26:40PM +0000, Meta via Digitalmars-d wrote:
> On Monday, 2 March 2015 at 15:46:28 UTC, Francesco Cattoglio wrote:
> >Taken from
> >trying to instantiate an Array!MyClass fails with a rather obscure
> >error message if the MyClass has a member function "void init()":
> >Is this a std library bug, or should this be considered a mistake on
> >the library user side to name a member function "init"?
> It's kind of ridiculous that the compiler doesn't complain about this,
> considering that defining an init member causes an error that you
> would have no idea how to fix unless you already knew about this
I say file the bug against the compiler, not the library. The compiler
should reject members named 'init' because .init already has a special
meaning in the language.
Being able to learn is a great learning; being able to unlearn is a greater learning.
More information about the Digitalmars-d