[Issue 932] New: static foreach in second template instantiation uses wrong tupleof

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 6 03:06:17 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=932

           Summary: static foreach in second template instantiation uses
                    wrong tupleof
           Product: D
           Version: 1.00
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: fvbommel at wxs.nl


---
void Fields(C)()
{
    foreach(i, a; typeof(C.tupleof))
    {
        // fails for second instantiation:
        // "test.d(7): static assert  (is(int == real)) is false"
        static assert(is(typeof(a) == typeof(C.tupleof)[i]));
    }
}

struct MyStruct1 {
    int afield;
}

struct MyStruct2 {
    real afield;
}

void main() {
    Fields!(MyStruct1);
    Fields!(MyStruct2);
}
---

Reduced from code by Kyle Furlong, posted at
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.bugs&article_id=10262

I tested this on v1.00 and v1.002-v1.005, all fail above assert.

(keyword "wrong-code" because this causes wrong code generation, though with
the static assert it of course doesn't compile. See the original example (at
link above) for a program that compiles and produces wrong code)


-- 



More information about the Digitalmars-d-bugs mailing list