dip1000 and preview in combine to cause extra safety errors

Steven Schveighoffer schveiguy at gmail.com
Mon Jun 13 18:09:35 UTC 2022


On 6/13/22 9:25 AM, deadalnix wrote:
> On Monday, 13 June 2022 at 12:02:31 UTC, John Colvin wrote:
>> Without expressing an opinion either way, I want to note that this has 
>> implications for `@nogc`. If you remove `scope` from the parameter of 
>> `foo`, the compiler won't let `main` be `@nogc` due to the slice 
>> literal allocation.
>>
>>     string foo(scope string s) @nogc {
>>         return s;
>>     }
>>
>>     void main() @nogc {
>>         foo(['a']);
>>     }
> 
> It's as if @nogc should track leaks and not allocations...

Wouldn't that be a leak if `['a']` was GC allocated?

-Steve


More information about the Digitalmars-d mailing list