DIP1000 scope inference
Paul Backus
snarwin at gmail.com
Tue Oct 25 02:20:27 UTC 2022
On Tuesday, 25 October 2022 at 02:13:20 UTC, rikki cattermole
wrote:
> On 25/10/2022 3:09 PM, Paul Backus wrote:
>> For example, the `@trusted` function below is memory safe when
>> using the current compiler release, but will become unsafe
>> when compiled with DMD 2.101:
>>
>> ```d
>> @trusted int[] example()
>> {
>> scope example = [1, 2, 3];
>> return example;
>> }
>> ```
>
> Does this also apply to @safe?
No, because you are not allowed to return a `scope` variable in
`@safe` code, even if you happen to know that it points to a heap
allocation.
More information about the Digitalmars-d
mailing list