www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20937] New: std.range.array of a lengthless range with


          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 puremagic.com
          Reporter: pro.mathias.lang 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
What I got:
foo.d(13): Error:  safe function D main cannot call  system function
std.array.array!(FilterResult!(__lambda1, immutable(S)[])).array
std.array.array!(FilterResult!(__lambda1, immutable(S)[])).array is declared

Jun 16 2020