Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 22, 2011 [Issue 6838] New: Covariant return types don't work with static arrays | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6838 Summary: Covariant return types don't work with static arrays Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: pszturmaj@tlen.pl --- Comment #0 from Piotr Szturmaj <pszturmaj@tlen.pl> 2011-10-22 09:07:48 PDT --- This is an example from http://d-programming-language.org/function.html, but with changed return types: class Foo { int[] test() { return null; } } class Bar : Foo { int[2] test() { return [1, 2]; } // overrides and is covariant with Foo.test() } // and here's additional test code: void main() { Foo f = new Bar(); auto arr = f.test(); assert(arr.length == 2); } This code compiles but fails on assert. Returned arr.length is 1 and accessing the first element of that array results in access violation. Given that static arrays are implicitly convertible to dynamic arrays, it should work. If not, it at least should not compile. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
April 21, 2012 [Issue 6838] Covariant return types don't work with static arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Piotr Szturmaj | http://d.puremagic.com/issues/show_bug.cgi?id=6838 SomeDude <lovelydear@mailmetrash.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lovelydear@mailmetrash.com --- Comment #1 from SomeDude <lovelydear@mailmetrash.com> 2012-04-20 17:00:57 PDT --- This no longer compiles on 2.059 Win32: PS E:\DigitalMars\dmd2\samples> rdmd bug.d bug.d(6): Error: function bug.Bar.test of type int[2u]() overrides but is not covariant with bug.Foo.test of type int[]() Failed: "dmd" "-v" "-o-" "bug.d" "-I." PS E:\DigitalMars\dmd2\samples> -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 01, 2012 [Issue 6838] Covariant return types don't work with static arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Piotr Szturmaj | http://d.puremagic.com/issues/show_bug.cgi?id=6838 --- Comment #2 from SomeDude <lovelydear@mailmetrash.com> 2012-05-01 15:28:26 PDT --- Should be closed as FIXED. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 04, 2012 [Issue 6838] Covariant return types don't work with static arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Piotr Szturmaj | http://d.puremagic.com/issues/show_bug.cgi?id=6838 SomeDude <lovelydear@mailmetrash.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #3 from SomeDude <lovelydear@mailmetrash.com> 2012-05-04 16:06:07 PDT --- Code returns a sound compilation error. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation