dip1000 and preview in combine to cause extra safety errors

Tejas notrealemail at gmail.com
Wed Jun 8 16:31:47 UTC 2022


On Wednesday, 8 June 2022 at 16:16:37 UTC, deadalnix wrote:
> On Wednesday, 8 June 2022 at 16:01:55 UTC, John Colvin wrote:
>> On Wednesday, 8 June 2022 at 15:58:10 UTC, John Colvin wrote:
>>> [...]
>>
>> E.g. this prints `["o", "o", "o", "o", "o"]` regardless of 
>> compiler flags
>>
>>     string foo(scope string s)
>>     {
>>         return s;
>>     }
>>
>>     void main()
>>     {
>>         import std.stdio;
>>         string[] result;
>>         foreach(c; "hello")
>>         {
>>             result ~= foo([c]);
>>         }
>>         writeln(result);
>>     }
>
> There is no frame of reference in which this result is in any 
> way reasonable.

Yeah, shouldn't the compiler complain that `s` is trying to 
escape the scope of `foo`?


More information about the Digitalmars-d mailing list