more enum and pragma troubles
captaindet
2krnk at gmx.net
Fri Aug 16 22:22:31 PDT 2013
are these bugs or expected behavior? (2 issues, see code below)
i thought enums are just compile time copy&paste magic so i cannot think of a reason why it should not be available at compile time...
if buggy, what is broken, enum (really bad) or pragma(msg,...) (worse enough)?
and are they in bugzilla already? (looked but nothing caught my eye)
if expected behavior, can someone pls explain.
cheers /det
import std.stdio;
enum Test{
test2 = 2,
test4 = 4
}
enum foo = Test.test2;
Test bar = Test.test4;
pragma( msg, foo ); // why does it print: cast(Test)2
// it should be: test2
// or at least simply: 2
// pragma( msg, bar ); // Error: variable bar cannot be read at compile time
void main(){
writeln( typeof(foo).stringof, " = ", foo );
// prints as expected: Test = test2
writeln( typeof(bar).stringof, " = ", bar );
// prints as expected: Test = test4
}
More information about the Digitalmars-d-learn
mailing list