www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10753] New: std.array.array of a range of structs with immutable fields too

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10753

           Summary: std.array.array of a range of structs with immutable
                    fields too
           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


--- Comment #0 from bearophile_hugs eml.cc 2013-08-03 07:02:11 PDT ---
import std.algorithm: map;
import std.array: array;
struct Foo {
    immutable dchar d;
}
struct Bar {
    immutable int x;
}
void main() {
    "12".map!Foo.array;
    [1, 2].map!Bar.array;
}



DMD 2.064alpha gives:

...\dmd2\src\phobos\std\array.d(2309): Error: cannot modify struct delegate
Foo[]()

{

return (cast(Foo*)(*this._data).arr)[len..len + 1u];

}

()[0u] Foo with immutable members
...\dmd2\src\phobos\std\array.d(69): Error: template instance
std.array.Appender!(Foo[]).Appender.put!(Foo) error instantiating
temp.d(10):        instantiated from here: array!(MapResult!(Foo, string))
temp.d(10): Error: template instance std.array.array!(MapResult!(Foo, string))
error instantiating
...\dmd2\src\phobos\std\array.d(58): Error: cannot modify struct result[i] Bar
with immutable members
temp.d(11): Error: template instance std.array.array!(MapResult!(Bar, int[]))
error instantiating

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 03 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10753


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com


--- Comment #1 from monarchdodra gmail.com 2013-08-05 03:06:51 PDT ---
(In reply to comment #0)
 import std.algorithm: map;
 import std.array: array;
 struct Foo {
     immutable dchar d;
 }
 struct Bar {
     immutable int x;
 }
 void main() {
     "12".map!Foo.array;
     [1, 2].map!Bar.array;
 }
 
 
 
 DMD 2.064alpha gives:
 
 ...\dmd2\src\phobos\std\array.d(2309): Error: cannot modify struct delegate
 Foo[]()
 
 {
 
 return (cast(Foo*)(*this._data).arr)[len..len + 1u];
 
 }
 
 ()[0u] Foo with immutable members
 ...\dmd2\src\phobos\std\array.d(69): Error: template instance
 std.array.Appender!(Foo[]).Appender.put!(Foo) error instantiating
 temp.d(10):        instantiated from here: array!(MapResult!(Foo, string))
 temp.d(10): Error: template instance std.array.array!(MapResult!(Foo, string))
 error instantiating
 ...\dmd2\src\phobos\std\array.d(58): Error: cannot modify struct result[i] Bar
 with immutable members
 temp.d(11): Error: template instance std.array.array!(MapResult!(Bar, int[]))
 error instantiating
This is an interesting scenario, as it reveals bugs in several steps of the "tool chain". In regards to "Bar", the first bug is in "std.array.array", and will soon be fixed. Unfortunately, it will pass through std.conv.emplace, which is not fixed, so it will stop working there. I have an open pull for fixing said conv, but I'm unsure it handles this scenario (I'm pretty confident it actually *doesn't*). I'll double check, but I don't think I'll make any changes to it to support this scenario, I'd rather make slow but confirmed steps to improving emplace. Still, this is an interesting bug. I'll check back to it often. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 05 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10753


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #2 from monarchdodra gmail.com 2013-08-28 02:17:47 PDT ---
*** This issue has been marked as a duplicate of issue 9528 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 28 2013