Summary: Statically disallow a init() method in structs
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: enhancement
          Priority: P2
         Component: DMD

--- Comment #0 from 2012-02-26 16:19:31 PST ---
This program comes from a reduction of a bug I've found:

struct Foo {
    void init() {}
void main() {
    Foo*[] foos;
    (*foos[0]).init(); // OK
    foos[0].init(); // Error: function expected before (), not null of type

I suggest to statically disallow the definition of a init() method in structs
(especially if they are a @property).

Some persons seem to agree.
See also the discussion:


Timon Gehr shows a case where defining a struct "init" method is useful, this
code compiles unless you de-comment the struct init. But maybe this is just a
bug in the implementation of @disable:

struct Foo {
    @disable this();
    // @disable enum init = 0;
void main() {
    Foo f = Foo.init;

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to