[Issue 23300] New: std.array : array wrongly propagates scopeness of source

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 20 21:05:23 UTC 2022


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

          Issue ID: 23300
           Summary: std.array : array wrongly propagates scopeness of
                    source
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: Ajieskola at gmail.com

This should compile but does not on dmd 2.100, using -preview=dip1000 flag.

-------------
@safe int[] fun()
{ import std : array, map;
  scope r = [1,2,3].map!"a+3";
  return r.array;
}
-------------

Were I returning `r` directly, this would be escaping a reference to scoped
data, but `array` copies the data. Returning `array`ed range should be allowed,
`scope` or no.

--


More information about the Digitalmars-d-bugs mailing list