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

== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article
On Sat, 15 May 2010 16:15:23 -0400, strtr <st...@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

Reply via email to