What can the community do to help D?

Denis Koroskin 2korden at gmail.com
Sat Oct 23 15:29:17 PDT 2010


On Sun, 24 Oct 2010 01:33:33 +0400, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Denis Koroskin:
>
>> FWIW, similar problem exists:
>>
>> class Foo
>> {
>>      void foo1()
>>      {
>>          struct Bar {}
>>      }
>>
>>      void foo2()
>>      {
>>          struct Bar { /* different set of fields and methods */ }
>>          // using Foo.foo2.Bar here
>>          // bang! linker errors
>>      }
>> }
>
> I have tried this, with no errors:
>
>
> class Foo {
>     void foo1() {
>         struct Bar { string s; }
>     }
>
>     void foo2() {
>         struct Bar { int x;
>             int spam() { return 1; }
>         }
>         Bar b = Bar(10);
>         int y = b.spam();
>     }
> }
>
> void main() {
>     auto f = new Foo;
>     f.foo2();
> }
>
>
> Are you able to show me code (or a bug report) that doesn't work?
>
> Bye,
> bearophile

Slightly modified yours and here we go:

class Foo {
     void foo1() {
         struct Bar {
             string s;
             void spam() {
             }
         }

         Bar b = Bar("hello");
         b.spam();
     }

     void foo2() {
         struct Bar {
             int x;
             int spam() { return 1; }
         }
         Bar b = Bar(10);
         int y = b.spam();
     }
}

void main() {
     auto f = new Foo;
     f.foo1();
//    f.foo2();	// uncommenting produces different crash
}


More information about the Digitalmars-d mailing list