dip1000 and preview in combine to cause extra safety errors

deadalnix deadalnix at gmail.com
Wed Jun 8 16:16:37 UTC 2022


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:
>>
>> The preview switch is changing the meaning of `in` which 
>> changes the signature of `foo` (which is then inconsistent 
>> with the implementation), which in turn will affect the call 
>> sites. This seems roughly as expected, no?
>
> 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.


More information about the Digitalmars-d mailing list