https://issues.dlang.org/show_bug.cgi?id=23300
Dennis <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #2 from Dennis <[email protected]> --- (In reply to RazvanN from comment #1) > However, `array`'s > parameter cannot be `scope` because it is copied into allocated memory. The parameter to `array` should infer `scope` unless the range has non-scope range primitives. It's not escaping the input array, it's dereferencing it and copying the elements into a new GC array which is not scope. `scope` inference fails and it falls back on `return scope` inference from `pure`. By making it impure, the newest DMD reports: test_.d(12): Error: scope variable `r` assigned to non-scope parameter `r` calling `array` std/array.d(112): which is not `scope` because of `__r353 = r` https://github.com/dlang/phobos/blob/b578dfad94770574d7e522557a77276c35943daa/std/array.d#L112 So the underlying problem is that `scope` inference is defeated by `foreach` on a struct with range primitives. --
