[Issue 7066] You can redefine .init and .stringof without error
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon May 14 06:20:03 UTC 2018
    
    
  
https://issues.dlang.org/show_bug.cgi?id=7066
Vijay Nayar <madric at gmail.com> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |madric at gmail.com
--- Comment #9 from Vijay Nayar <madric at gmail.com> ---
I encountered this problem as well while porting a C++ library to D.  It took a
while to diagnose, but I eventually found out that the mere existence of a
function named "init" caused the RefAppender I used in a totally unrelated
function to break.
Example program:
```
import std.array;
struct S1 {
  // The mere presence of this method causes the error, deleting it fixes the
error.
  void init(string p1, int p2, int p3) { }
}
struct S2 {
  S1[] a;
  RefAppender!(int[]) getAppender() {
    return appender(&a);
  }
}
void main() { }
```
The actual error produced is obvious only because the arguments I put on init
in this example, but normally it's pretty bizarre:
```
/dlang/dmd/linux/bin64/../../src/phobos/std/array.d(2907): Error: cannot have
array of `void(string, int, int)`
/dlang/dmd/linux/bin64/../../src/phobos/std/array.d(2976): Error: cannot have
array of `inout void(string, int, int)`
/dlang/dmd/linux/bin64/../../src/phobos/std/array.d(3369): Error: template
instance `std.array.Appender!(S1[])` error instantiating
/dlang/dmd/linux/bin64/../../src/phobos/std/array.d(3879):        instantiated
from here: `RefAppender!(S1[])`
onlineapp.d(12):        instantiated from here: `appender!(S1[]*, S1)`
/dlang/dmd/linux/bin64/../../src/phobos/std/array.d(3429): Error: cannot have
array of `inout void(string, int, int)`
```
--
    
    
More information about the Digitalmars-d-bugs
mailing list