dip1000 and preview in combine to cause extra safety errors

Walter Bright newshound2 at digitalmars.com
Wed Jun 8 23:28:04 UTC 2022


On 6/8/2022 11:32 AM, Timon Gehr wrote:
> Your code is literally calling this function:
> 
> ```d
> string foo(scope string s){ return s; }
> ```
> 
> This causes UB, therefore you can't blame the compiler frontend here. I guess 
> you can complain about the language specification, but what else are you 
> expecting `scope` to do? There could be some more diagnostics I guess, like for 
> the case where a stack variable is escaped directly.

Annotating foo() with @scope yields:

     test6.d(5): Deprecation: scope variable `s` may not be returned


More information about the Digitalmars-d mailing list