[Issue 20595] there should be a way to suggest that `auto` return will only be of certain types
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Fri Mar 31 12:17:58 UTC 2023
    
    
  
https://issues.dlang.org/show_bug.cgi?id=20595
Nick Treleaven <nick at geany.org> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick at geany.org
--- Comment #1 from Nick Treleaven <nick at 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).
--
    
    
More information about the Digitalmars-d-bugs
mailing list