Thread overview
[Issue 7597] Statically disallow a init() method in structs
Jul 25, 2014
davidsp@fb.com
Apr 21, 2020
FeepingCreature
Dec 17, 2022
Iain Buclaw
July 25, 2014
https://issues.dlang.org/show_bug.cgi?id=7597

davidsp@fb.com changed:

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

--- Comment #2 from davidsp@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".

--
April 21, 2020
https://issues.dlang.org/show_bug.cgi?id=7597

FeepingCreature <default_357-line@yahoo.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |default_357-line@yahoo.de

--- Comment #3 from FeepingCreature <default_357-line@yahoo.de> ---
*reaches up*

> It has been [0] days since a user was hit by this bug.

There's simply no value to this. If you want a constructor, write a constructor. Overriding "T.init" is always an error, and should be reported as one by the compiler.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=7597

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P4

--