Cannot interpret struct at compile time
Robert Clipsham
robert at octarineparrot.com
Sat May 7 15:17:14 PDT 2011
Hey all,
I was wondering if anyone could enlighten me as to why the following
code does not compile (dmd2, latest release or the beta):
----
struct Foo
{
int a;
}
string test()
{
string str = "struct " ~ Foo.stringof ~ "_{";
foreach (j, f; Foo.tupleof)
{
enum fullFieldName = Foo.tupleof[j].stringof;
str ~= typeof(f).stringof ~ ' ' ~
fullFieldName[Foo.stringof.length + 3 .. $];
}
return str ~ "}";
}
void main()
{
mixin(test());
}
----
If fails with the errors:
test.d(9): Error: Cannot interpret Foo at compile time
test.d(19): Error: cannot evaluate test() at compile time
test.d(19): Error: argument to mixin must be a string, not (test())
test.d(19): Error: cannot evaluate test() at compile time
test.d(19): Error: argument to mixin must be a string, not (test())
Thanks,
--
Robert
http://octarineparrot.com/
More information about the Digitalmars-d-learn
mailing list