April 18, 2023 [Issue 23844] New: chain(only) doesn't support immutable structs | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23844 Issue ID: 23844 Summary: chain(only) doesn't support immutable structs Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: minor Priority: P1 Component: phobos Assignee: nobody@puremagic.com Reporter: default_357-line@yahoo.de Consider this code: ``` void main() { import std.array : array; import std.range : chain, only; struct S { immutable int value; } auto range = chain(only(S(5)), only(S(6))); assert(range.array == [S(5), S(6)]); } ``` It errors with a flood of ``` std/range/package.d(1172): Error: cannot modify struct instance `result.__source_field_0` of type `OnlyResult!(S)` because it contains `const` or `immutable` members ``` If I remove `immutable`, it works. -- |
Copyright © 1999-2021 by the D Language Foundation