[swift-evolution] Disallowing unreachable code

Joe Groff jgroff at apple.com
Wed Mar 29 19:07:02 CDT 2017


> On Mar 29, 2017, at 8:11 AM, John McCall via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> On Mar 29, 2017, at 9:15 AM, Alex Blewitt <alblue at apple.com> wrote:
>>> On 29 Mar 2017, at 14:10, Jonathan Hull <jhull at gbis.com> wrote:
>>> 
>>> I think the idea is that it also adds a warning so you can find it later.
>> 
>> @available(*, deprecated, message: "Don't forget to implement this")
>> func unimplemented<T>(_ file:String = #file,_ line:Int = #line) -> T {
>>   fatalError("Not implemented \(file):\(line)")
>> }
>> 
>> let f: String = unimplemented()
> 
> I was suggesting that it would be a useful addition to the language, not that it
> necessarily needed new compiler support.
> 
> Does someone want to write a proposal for it?

Placeholder expressions in fact have this exact behavior in "playgrounds mode" already. We could easily make it so that placeholders warn rather than error in normal source code as well.

-Joe


More information about the swift-evolution mailing list