https://issues.dlang.org/show_bug.cgi?id=23300
RazvanN <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from RazvanN <[email protected]> --- (In reply to Ate Eskola from comment #0) > 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. The problem here is that `r` is `scope` so for it to be able to be passed to `array`, `array` also needs to receive a scope parameter. However, `array`'s parameter cannot be `scope` because it is copied into allocated memory. By the current scope rules this seems to be correct behavior, making this bug report invalid. --
