dip1000 and preview in combine to cause extra safety errors

Dennis dkorpel at gmail.com
Thu Jun 9 12:45:31 UTC 2022


On Thursday, 9 June 2022 at 00:38:13 UTC, Timon Gehr wrote:
> ```d
> int* foo()@system{
>     int x;
>     return &x; // error
> }
>
> int* foo(ref int x)@system{
>     return &x; // error
> }
>
> int* foo(scope int* x)@system{
>     return x; // ok
> }
> ```
>
> This does not have anything to do with `@safe` by default, it's 
> just an inconsistency in the compiler implementation.

I noticed this as well, and as of 
https://github.com/dlang/dmd/pull/14107 the `&ref` escape is 
treated the same as returning a scope pointer (error in @safe 
code only). Returning &local directly is still an error in 
@system code, that error predates @safe and dip1000.


More information about the Digitalmars-d mailing list