Thread overview
[Issue 20595] there should be a way to suggest that `auto` return will only be of certain types
Dec 17, 2022
Iain Buclaw
Mar 31, 2023
Nick Treleaven
Oct 24, 2023
Basile-z
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=20595

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

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

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick@geany.org

--- Comment #1 from Nick Treleaven <nick@geany.org> ---
You can already do this with an OutStatement with a static assert:

auto f()
out (r)
{
    static assert(is(typeof(r) : int));
}
do
{
    return "";
}

Compiling this you get an error, and the out contract should/could be shown in the docs (haven't checked).

--
October 24, 2023
https://issues.dlang.org/show_bug.cgi?id=20595

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=24197

--