Thread overview
[Issue 22509] Invalid implicit conversion from int* to immutable(int*)
Nov 13, 2021
timon.gehr@gmx.ch
[Issue 22509] Document implicit conversion to immutable for pure factory functions
Nov 13, 2021
timon.gehr@gmx.ch
Dec 17, 2022
Iain Buclaw
Mar 05, 2023
Nick Treleaven
Mar 05, 2023
Nick Treleaven
November 13, 2021
https://issues.dlang.org/show_bug.cgi?id=22509

thomas.bockman@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid

--
November 13, 2021
https://issues.dlang.org/show_bug.cgi?id=22509

thomas.bockman@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|accepts-invalid             |spec

--- Comment #1 from thomas.bockman@gmail.com ---
Apparently, this is a deliberate feature not yet documented in the spec. Forum
discussion:
    https://forum.dlang.org/post/smo115$io7$1@digitalmars.com

--
November 13, 2021
https://issues.dlang.org/show_bug.cgi?id=22509

timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr@gmx.ch
          Component|dmd                         |dlang.org
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #2 from timon.gehr@gmx.ch ---
Changed component to spec.

--
November 13, 2021
https://issues.dlang.org/show_bug.cgi?id=22509

timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Invalid implicit conversion |Document implicit
                   |from int* to                |conversion to immutable for
                   |immutable(int*)             |pure factory functions

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=22509

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
March 05, 2023
https://issues.dlang.org/show_bug.cgi?id=22509

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |nick@geany.org
         Resolution|---                         |INVALID

--- Comment #3 from Nick Treleaven <nick@geany.org> ---
>    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.

--
March 05, 2023
https://issues.dlang.org/show_bug.cgi?id=22509

--- Comment #4 from Nick Treleaven <nick@geany.org> ---
> A.ptr is a template

I meant A.ptr is inside the A template.

--