April 04, 2006 [Bug 85] New: Array of classes doesn't function as array of interfaces | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/bugzilla/show_bug.cgi?id=85 Summary: Array of classes doesn't function as array of interfaces Product: D Version: 0.151 Platform: PC OS/Version: Windows Status: NEW Keywords: wrong-code Severity: critical Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: deewiant@gmail.com Testcase below - originally posted as a comment in Bug 65. Note that while this can be worked around simply by changing the Class[] to I[], the code as it is below generates an incorrect program. ------------------ interface I { I[] foo(); uint x(); } class Class : I { I[] foo() { // changing this to I[] f = new Class[1] fixes the bug Class[] f = new Class[1]; f[0] = new Class; return f; } uint x() { return 0; } } void main() { Class c = new Class(); assert (c.x == 0); assert (c.foo[0].x == 0); } ------------------ -- |
April 06, 2006 Re: [Bug 85] New: Array of classes doesn't function as array of interfaces | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail Attachments: | d-bugmail@puremagic.com schrieb am 2006-04-04: > Testcase below - originally posted as a comment in Bug 65. > > Note that while this can be worked around simply by changing the Class[] to I[], the code as it is below generates an incorrect program. > > ------------------ > interface I { > I[] foo(); > uint x(); > } > > class Class : I { > I[] foo() { > // changing this to I[] f = new Class[1] fixes the bug > Class[] f = new Class[1]; > f[0] = new Class; > return f; > } > > uint x() { > return 0; > } > } > > void main() { > Class c = new Class(); > assert (c.x == 0); > assert (c.foo[0].x == 0); > } > ------------------ Added to DStress as http://dstress.kuehne.cn/run/i/interface_24_A.d http://dstress.kuehne.cn/run/i/interface_24_B.d http://dstress.kuehne.cn/run/i/interface_24_C.d http://dstress.kuehne.cn/run/i/interface_24_D.d Thomas |
Copyright © 1999-2021 by the D Language Foundation