Three legitimate bugs? (D1.061)

Steven Schveighoffer schveiguy at yahoo.com
Mon May 17 07:33:47 PDT 2010


On Mon, 17 May 2010 10:28:47 -0400, strtr <strtr at spam.com> wrote:

> == Quote from Steven Schveighoffer (schveiguy at yahoo.com)'s article
>> On Sat, 15 May 2010 16:15:23 -0400, strtr <strtr at spam.com> wrote:
>> > Should I report these bugs?
>> > (and how should I call this first one?)
>> > ----
>> > module main;
>> > //const S S1 = S(); // uncomment this to compile
>> > struct S
>> > {
>> >   float value;
>> >   static S opCall()
>> >   {
>> >     S s;
>> >     return s;
>> >   }
>> >   const S S2 = S();
>> > }
>> > void main(){}
>> > --
>> > main.d(4): Error: struct main.S no size yet for forward reference
>> > main.d(4): Error: struct main.S no size yet for forward reference
>> > main.d(11): Error: cannot evaluate opCall() at compile time
>> > ----
>> Unlike some languages, D1 const does not imply static.  Which means you
>> are trying to define an S as containing an S, which would then contain
>> another S and so on.  This should work:
>>   struct S
>>   {
>>     float value;
>>     static S opCall()
>>     {
>>       S s;
>>       return s;
>>     }
>>     static const S S2 = S();
>>   }
>> -Steve
>
> But why would uncommenting S1 result in compilable code?
>

Hm... that's a good question.  I guess my belief is wrong.  And that would  
imply that my code doesn't compile...

-Steve


More information about the Digitalmars-d-learn mailing list