Thread overview
[Issue 22982] Can't copy scope range elements into a returned array
Apr 04, 2022
Atila Neves
Apr 04, 2022
Dennis
Apr 07, 2022
Atila Neves
Apr 07, 2022
ag0aep6g
April 04, 2022
https://issues.dlang.org/show_bug.cgi?id=22982

Atila Neves <atila.neves@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid, safe

--
April 04, 2022
https://issues.dlang.org/show_bug.cgi?id=22982

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dkorpel@live.nl
         Resolution|---                         |INVALID

--- Comment #1 from Dennis <dkorpel@live.nl> ---
The `only` range here is essentially a static array of `scope` strings. You can't put scope strings in a dynamic array, because `scope` semantics aren't transitive, so the error is correct.

--
April 07, 2022
https://issues.dlang.org/show_bug.cgi?id=22982

--- Comment #2 from Atila Neves <atila.neves@gmail.com> ---
I don't know if transitivity has anything to do with it, since the element is scope.

Conceptually, I think return scope on `only` should allow me to return an array from it.

--
April 07, 2022
https://issues.dlang.org/show_bug.cgi?id=22982

ag0aep6g <ag0aep6g@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g@gmail.com

--- Comment #3 from ag0aep6g <ag0aep6g@gmail.com> ---
(In reply to Atila Neves from comment #2)
> I don't know if transitivity has anything to do with it, since the element is scope.
> 
> Conceptually, I think return scope on `only` should allow me to return an array from it.

`scope` is not a type qualifier. You cannot have a dynamic array of `scope`
things. `scope` always applies to the outermost indirection(s) of a variable
(ignoring `ref`).

If you think `scope` should work differently, you will probably have to re-design the whole thing.

--