Three legitimate bugs? (D1.061)
strtr
strtr at spam.com
Mon May 17 07:28:47 PDT 2010
== 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?
More information about the Digitalmars-d-learn
mailing list