[Issue 20937] New: std.range.array of a lengthless range with indirection is not @safe
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 16 10:47:51 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20937
Issue ID: 20937
Summary: std.range.array of a lengthless range with indirection
is not @safe
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: safe
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: pro.mathias.lang at gmail.com
```
import std.algorithm;
import std.array;
struct S
{
ulong[] values;
}
void main () @safe
{
immutable arr = [ S([1]), S([2]), S([3]), S([4]), S([42]), S([84]),
S([121]) ];
auto intermediate = arr.filter!(v => !!(v.values[0] % 2));
auto result = intermediate.array;
}
```
What I expected: `result` should be of a type that converts to
`immutable(S)[]`.
What I got:
```
foo.d(13): Error: @safe function D main cannot call @system function
std.array.array!(FilterResult!(__lambda1, immutable(S)[])).array
/usr/local/opt/dmd/include/dlang/dmd/std/array.d(102):
std.array.array!(FilterResult!(__lambda1, immutable(S)[])).array is declared
here
```
--
More information about the Digitalmars-d-bugs
mailing list