[swift-evolution] Proposal: Initialization should not be required in precondition(false) case.

Amir Michail a.michail at me.com
Fri Feb 12 11:15:40 CST 2016


> On Feb 12, 2016, at 12:09 PM, Radosław Pietruszewski <radexpl at gmail.com> wrote:
> 
> I think what you mean is `fatalError()`.
> 
> You can’t do what you suggest, because you can’t prove that the expression passed to precondition will evaluate to false. (You theoretically could if the compiler checked for you passing `false`, but that makes no sense. Just go with `fatalError` or `preconditionFailure`.)
> 

What’s wrong with having the compiler explicitly check for “false”?

> — Radek
> 
>> On 12 Feb 2016, at 16:59, Amir Michail via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> For example:
>> 
>> let x:Int
>> if … { x = 1 }
>> else if … { x = 2 }
>> else { precondition(false) } // no initialization needed
>> 
>> Similarly,
>> 
>> let x:Int
>> switch ... {
>> case …: x = 1
>> case …: x = 2
>> default: precondition(false) // no initialization needed
>> }
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 



More information about the swift-evolution mailing list