class test
{
static char[] c(){return "whateever;";}
int a;
class b
{
mixin(c());
}
}
void main()
{
}
after reviewing the document i think my example above should be compilable
Comment #1 by bugzilla — 2007-03-21T13:16:43Z
Static strings can be modified at runtime, which is why this isn't compilable (it must be known at compile time). Try doing static const char[] instead, that should work.
Comment #2 by fvbommel — 2007-03-21T18:29:08Z
(From comment #0)
> static char[] c(){return "whateever;";}
(In reply to comment #1)
> Static strings can be modified at runtime, which is why this isn't compilable
> (it must be known at compile time). Try doing static const char[] instead, that
> should work.
That's not a static string, that's a static method he's trying to use for CTFE...
(Reopening not because I'm sure this should be allowed, but because it was IMHO closed for the wrong reason)
Comment #3 by davidl — 2007-03-22T00:43:24Z
class test
{
static const char[] c(){return "whateever;";}
int a;
class b
{
mixin(c());
}
}
void main()
{
}
even above ain't compilabe
Comment #4 by smjg — 2007-03-23T13:38:06Z
I don't quite see why it should. It would be equivalent to
class test
{
int a;
class b
{
whateever;
}
}
but "whateever;" isn't a valid declaration.
If that's just a placeholder, using placeholders like this in code samples isn't a good idea. The problem could still be down to what you're trying to use in that place. Always use something that a user can test straight out of the box.
Comment #5 by davidl — 2007-03-27T23:49:16Z
class test
{
static char[] c(){return "this(){};";}
int a;
class b
{
mixin(c());
}
}
void main()
{
}
heh, this is an example should be compilable ;)