[dmd-internals] Don's CTFE overhaul – bug reports?

David Nadlinger code at klickverbot.at
Sun Apr 17 16:55:45 PDT 2011


Another regression present in Git master (186b6a0):

---
class Foo {
     void bar() {}
}

string[] getSymbols(C)() {
     string[] result;
     foreach(s; __traits(derivedMembers, C)) {
         result ~= s;
     }
     return result;
}

enum s = getSymbols!Foo();

// Prints »string[]: bar, length: 3u« instead of
// »string[]: ["bar"], length: 1u«.
pragma(msg, typeof(s), ": ", s, ", length: ", s.length);

// Trying to access something fails with:
// »integral constant must be scalar type, not string«.
enum f = s[0];
---

Somehow, s seems to refer to the element of the string[] array ("bar"), 
instead of to the array itself (["bar"]).

David


More information about the dmd-internals mailing list