www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22561] New: only().joiner fails with immutable element type

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

          Issue ID: 22561
           Summary: only().joiner fails with immutable element type
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

import std;

immutable struct Foo {
    int[] r;
}

void main() { 
    auto foo = [5].map!(a => only(Foo(null))).joiner;
}

expected: compiles
got: flood of errors

/dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/iteration.d-mixin-3601(3616):
Error: cannot modify struct instance `this._current` of type
`OnlyResult!(immutable(Foo))` because it contains `const` or `immutable`
members

--
Dec 03 2021