proposed @noreturn attribute

Meta via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 11 10:37:20 PDT 2017


On Monday, 10 July 2017 at 20:00:10 UTC, Steven Schveighoffer 
wrote:
> This means that you get errors for some instantiations. Which 
> ironically means you'd need to do something like this:
>
> void foo(alias f)()
> {
>    f();
>    static if(!isNoreturn!f)
>    {
>        auto a = 5;
>        ...// etc.
>    }
> }
>
> Today, it's not a big issue. We can't alias `assert` function 
> directly, so it's obvious where it's an assert or not (because 
> you have to spell it out!).
>
> We have similar problems today with generic code causing 
> unreachability errors. See for instance 
> https://issues.dlang.org/show_bug.cgi?id=14835
>
> -Steve

I think that for our own sanity the dead-code check would have to 
be disabled in this case. I agree that it'd be awful putting 
`static if (!isNoReturn!f)` everywhere.

Actually, why not just disable it entirely in templated functions?


More information about the Digitalmars-d mailing list