dip1000 and preview in combine to cause extra safety errors
Timon Gehr
timon.gehr at gmx.ch
Thu Jun 9 13:00:01 UTC 2022
On 09.06.22 14:45, Dennis wrote:
> 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.
Well, not a big fan. This is the wrong way around.
More information about the Digitalmars-d
mailing list