www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13199] New: const std.container.SList iteration

https://issues.dlang.org/show_bug.cgi?id=13199

          Issue ID: 13199
           Summary: const std.container.SList iteration
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

It's not easy to iterate on a SList in a post-condition:


import std.container: SList;
auto foo()
out (result) {
    foreach (x; result) {}
    foreach (x; result[]) {}
} body {
    SList!int sl;
    return sl;
}
void main() {}


dmd 2.066beta4 gives:

test.d(4,5): Error: no property 'popFront' for type 'const(SList!int)'
test.d(4,5): Error: mutable method std.container.slist.SList!int.SList.front is
not callable using a const object
test.d(5,23): Error: mutable method std.container.slist.SList!int.SList.opSlice
is not callable using a const object

--
Jul 24 2014