Re: Pure Factory Functions 💔 `inout`
ag0aep6g
anonymous at example.com
Tue Feb 21 15:14:26 UTC 2023
On 21.02.23 15:31, ag0aep6g wrote:
> On 21.02.23 14:58, Quirin Schroll wrote:
>> ```d
>> @safe:
>>
>> int* foo(double[] xs) pure
>> {
>> if (xs.length >= 2)
>> xs[0] = xs[$ - 1];
>> return new int;
>> }
>>
>> void main()
>> {
>> double[] xs = [];
>> immutable a = foo(xs);
>> }
>> ```
>
> That right there is nothing but a safety hole.
I did some digging and found `-preview=fixImmutableConv`. With that, the
code fails compilation as it should. So this is a known issue and it's
already in the process of getting fixed.
More information about the Digitalmars-d
mailing list