[Issue 23844] New: chain(only) doesn't support immutable structs
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 18 11:41:58 UTC 2023
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 at puremagic.com
Reporter: default_357-line at 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.
--
More information about the Digitalmars-d-bugs
mailing list