[Issue 856] New: foreach doesn't work when accessing elements as supertypes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 19 00:01:14 PST 2007


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

           Summary: foreach doesn't work when accessing elements as
                    supertypes
           Product: D
           Version: 1.00
          Platform: PC
               URL: http://dstress.kuehne.cn/run/c/cast_29_B.d
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: braddr at puremagic.com


module dstress.run.c.cast_29_B;

class Foo{
}

class Bar : Foo{
}

int main(){
        Bar[] bars=new Bar[100];

        foreach(Foo f; bars){
                return 0;
        }

        assert(0);
}

$ dmd cast_29_B.d
cast_29_B.d(12): Error: foreach: Bar[] is not an array of
dstress.run.c.cast_29_B.Foo


-- 



More information about the Digitalmars-d-bugs mailing list