Summary: static foreach over a string[] no longer produces
                    directly usable strings
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: regression
          Priority: P3
         Component: DMD

--- Comment #0 from Rob Jacques <> 2011-06-28 18:43:41 PDT ---
In DMD 2.052 and prior one could perform a static foreach over static string
arrays, such as those produced by traits. However, in DMD 2.053 one has to
'touch' the string before use.

void main(string[] args) {
    struct Foobar { real x; real y; real z;};
    switch("x") {
        foreach(i,member; __traits(allMembers, Foobar)) {
            case member : break; // Valid in 2.052
            //But in DMD 2.053 this produces an error
            //Error: case must be a string or an integral constant, not member

            // Required workaround for DMD 2.053
            //case member[] : break; 
            //case member~"" : break;

Also, and I'm not sure if this is a regression or not, if used the pointer of
member is not valid i.e. you can not use writeln(member);, etc. Although both i
and member.length produce correct results.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to