pure factory function vs immutable(Foo)**

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 11 11:12:43 PDT 2017


On 07/10/2017 04:57 PM, ag0aep6g wrote:
> ----
> alias T = int;
> 
> T** f(const T** input) pure
> {
>      T** output;
>      return output;
> }
> 
> void main()
> {
>      T i;
>      T* p = &i;
>      immutable T** r = f(&p);
> }
> ----
[...]
> Now change `T` to `alias T = immutable int;`. The program gets rejected. 
> The error message is: "cannot implicitly convert expression (f(& p)) of 
> type immutable(int)** to immutable(int**)".

Filed an issue:
https://issues.dlang.org/show_bug.cgi?id=17635


More information about the Digitalmars-d-learn mailing list