Comment #0 by qs.il.paperinik — 2016-09-16T13:29:46Z
struct X(T)
{
this(S)(in S[] arr) // inferred pure
{ }
}
void main() pure
{
X!uint mut = [ 1, 2 ]; // proves inference (cf. main is pure)
// immutable X!uint imm1 = [ 1, 2 ];
// auto imm2 = immutable X!uint([1, 2]);
}
The last lines don't compile. However, they do if the inferred pure is explicitly annotated.
From the discussion
https://forum.dlang.org/post/[email protected]
Comment #1 by stanislav.blinov — 2021-12-21T18:44:55Z
I would strongly suggest constructors which are inferred pure, as opposed to explicitly annotated, MUST NOT be considered for uniqueness. Doing otherwise can lead to unexpected changes in program behavior, silent bugs. See the related issue for rationale.
Comment #2 by robert.schadek — 2024-12-13T18:50:08Z