> immutable immutA = a.ptr; // Accepts invalid!
That is valid. A.ptr is a template so it gets attributes inferred (see below).
> immutable immutB = b.ptr; // Error: cannot implicitly convert expression `b.ptr()` of type `int*` to `immutable(int*)`
This error goes away if you add `pure` to B.ptr.
> this is a deliberate feature not yet documented in the spec
It is documented:
dlang.org/spec/function.html#pure-factory-functions
If you have any ideas on how the docs can be improved please let us know.
Comment #4 by nick — 2023-03-05T15:45:25Z
> A.ptr is a template
I meant A.ptr is inside the A template.