[swift-evolution] Disallowing unreachable code

Jonathan Hull jhull at gbis.com
Wed Mar 29 08:10:50 CDT 2017


I think the idea is that it also adds a warning so you can find it later.


> On Mar 29, 2017, at 6:06 AM, Alex Blewitt <alblue at apple.com> wrote:
> 
> On 29 Mar 2017, at 11:38, Jonathan Hull via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> 
>>> On Mar 27, 2017, at 11:27 AM, John McCall via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>> In fact, we should probably double-down on this design and add an "unimplemented" expression that always triggers warnings and just traps if you try to evaluate it. That expression would be a logical thing to use in e.g. code snippets automatically inserted by an IDE.
>> 
>> Yes, please.
> 
> 
> You can do this already:
> 
> func unimplemented<T>(_ file:String = #file,_ line:Int = #line) -> T {
>   fatalError("Not implemented \(file):\(line)")
> }
> 
> let f: String = unimplemented()
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170329/dd4c279d/attachment.html>


More information about the swift-evolution mailing list