[Issue 7597] Statically disallow a init() method in structs

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jul 24 17:53:26 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=7597

davidsp at fb.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |davidsp at fb.com

--- Comment #2 from davidsp at fb.com ---
We either should forbid a method named init (or any other valid type
properties) or require and explizit "override".

This isn't related to only structs, e.g.:

class A
{
  void init() {}
}

void t(T)()
{
  auto x = T.init;
}

int main(string[] args)
{
  t!A();
}

-> test.d(10): Error: need 'this' for 'init' of type 'void()'.

The bug is more: "Don't allow shadowing of type properties".

--


More information about the Digitalmars-d-bugs mailing list