<div dir="ltr">I also want to start a discussion (in a separate thread) about allowing @noreturn functions to "return" any type, so that the unreachable code checks can allow you to do things like "let value = fatalError()". For this sort of thing, I think it's nice that noreturn is not an actual uninhabited type, but has special meaning w.r.t. control flow, and could in fact be part of the type signature.<div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote">On Thu, Feb 25, 2016 at 2:51 PM, Radosław Pietruszewski <span dir="ltr"><<a href="mailto:radexpl@gmail.com" target="_blank">radexpl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">> On 25 Feb 2016, at 23:47, Joe Groff <<a href="mailto:jgroff@apple.com">jgroff@apple.com</a>> wrote:<br>
><br>
><br>
>> On Feb 25, 2016, at 2:43 PM, Radosław Pietruszewski <<a href="mailto:radexpl@gmail.com">radexpl@gmail.com</a>> wrote:<br>
>><br>
>>> On 25 Feb 2016, at 23:40, Joe Groff <<a href="mailto:jgroff@apple.com">jgroff@apple.com</a>> wrote:<br>
>>><br>
>>><br>
>>>> On Feb 25, 2016, at 2:40 PM, Radosław Pietruszewski <<a href="mailto:radexpl@gmail.com">radexpl@gmail.com</a>> wrote:<br>
>>>><br>
>>>> Ah, that’s a neat idea! Not sure it’s an improvement though to have a magic type that changes how the compiler treats your method, rather than a rather explicit *attribute* on the method…<br>
>>><br>
>>> There's no magic. If you can't construct a value of your return type, you can't return.<br>
>>><br>
>>> -Joe<br>
>><br>
>><br>
>> The magic is somewhere else. Calling a @noreturn function allows you to do things you can’t otherwise do:<br>
>><br>
>> func foo() -> Int {<br>
>> fatalError()<br>
>> }<br>
><br>
> I see. The unreachable code check arguably ought to also accept this if fatalError returns any uninhabited type, since it'll never be able return if that's the case.<br>
><br>
> -Joe<br>
<br>
</div></div>Would that actually be useful today? (i.e. aside from your idea) To me, having a NoReturn return type seems more magic and less obvious than an attribute.<br>
<br>
— Radek</blockquote></div><br></div></div>