digitalmars.D.bugs - [Issue 5074] New: array(immutable(int)[]) ==> int[]
- d-bugmail puremagic.com (36/36) Oct 18 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5074
- d-bugmail puremagic.com (10/10) Oct 19 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5074
- d-bugmail puremagic.com (11/12) Oct 19 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5074
http://d.puremagic.com/issues/show_bug.cgi?id=5074 Summary: array(immutable(int)[]) ==> int[] Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc This is more an enhancement request than a bug report. In my opinion an array() applied on an array has to act like "dup", just like array(static_array) returns a dynamic array. So I think array(immutable(int)[]) has to return an int[]. With DMD 2.049 array(immutable(int)[]) doesn't work: import std.array: array; void main() { int[4] a0 = [2, 3, 1, 4]; static assert(is(typeof(array(a0)) == int[])); // OK immutable(int)[] a1 = [2, 3, 1, 4]; int[] a2 = a1.dup; int[] a3 = array(a1); // ERROR } Errors generated: ...\dmd\src\phobos\std\array.d(64): Error: result[i] isn't mutable ...\dmd\src\phobos\std\array.d(7): Error: template instance std.array.array!(immutable(int)[]) error instantiating test.d(7): Error: cannot implicitly convert expression (array(a1)) of type immutable(int)[] to int[] -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 18 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5074 Andrei Alexandrescu <andrei metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrei metalanguage.com 06:18:19 PDT --- to!(int[])(a) should take care of that. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 19 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5074to!(int[])(a) should take care of that.There are also const casts: array(cast(int[])a1) But the design point of array() is to digest anything you may iterate, and produce a dynamic array. So I think array(immutable(int)[]) should not require casts or to!(). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 19 2010