Scope checking on static array struct doesn't kick in

Stanislav Blinov via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 9 06:24:51 PDT 2017


On Tuesday, 9 May 2017 at 12:25:29 UTC, Nordlöw wrote:
> On Tuesday, 9 May 2017 at 11:52:35 UTC, Nordlöw wrote:
>> I've tagged the ref-returning functions (in this case 
>> `opSlice`) with `return scope` for my statically allocated 
>> array struct at
>
> Here's a simpler example
>
> https://github.com/nordlow/phobos-next/blob/cf85f449d24981fbe6269f8096db23282e2fbb65/tests/test_scope.d

Looks like a bug, if you change "auto" to "int[]" it starts 
complaining in f(). I have a question though, why is the syntax 
like this:

> auto opSlice() return scope;

?

I don't see such in the DIP, proposed there is simply "scope" to 
the left of the declaration, i.e.

> scope auto opSlice();

Although with that syntax dmd complains about escaping 'this', as 
if it was scope { auto opSlice(); }.

Is 'return scope' the syntax that is supposed to be used and it's 
just not reflected in the DIP, or?..


More information about the Digitalmars-d-learn mailing list