[DIP1000] Something I don't quite understand regarding 'scope'

Stanislav Blinov stanislav.blinov at gmail.com
Mon Jun 29 00:28:07 UTC 2020


void local(Args...)(Args args)
{
}

void main() @safe
{
     import std.stdio;
     scope int* p;
     local(p);   // Ok
     writeln(p); // Error: scope variable p assigned to non-scope 
parameter _param_0 calling std.stdio.writeln!(int*).writeln
}

The signatures of `std.stdio.writeln` and `local` are the same 
(see `writeln` [1]). Yet, with '$ dmd -preview=dip1000' the call 
to `local` compiles, while the call to `writeln` doesn't.

Is that an instance of [2]?

[1] 
https://github.com/dlang/phobos/blob/v2.092.1/std/stdio.d#L3865
[2] https://issues.dlang.org/show_bug.cgi?id=20023


More information about the Digitalmars-d-learn mailing list