Re: [swift-evolution] Change default compiler fix for not-unwrapped Optional from ! To ?

2017-07-18 Thread Chris Lattner via swift-evolution
> On Jul 13, 2017, at 10:21 PM, Félix Cloutier via swift-evolution > wrote: > > How should the fix-it transform the following code to make it valid? > > func foo(bar: String) -> Int > func frob() -> String? > > func qaz() -> Int { > return foo(bar: frob()) //

Re: [swift-evolution] Change default compiler fix for not-unwrapped Optional from ! To ?

2017-07-18 Thread Robert Bennett via swift-evolution
Another example of the compiler being not so helpful: func f(completion: (()->())? = nil) { completion() } The compiler offers to insert a ! after `completion`, which is a strictly worse choice than inserting a ?. > On Jul 15, 2017, at 7:48 AM, Rod Brown

Re: [swift-evolution] Change default compiler fix for not-unwrapped Optional from ! To ?

2017-07-15 Thread Rod Brown via swift-evolution
> On 15 Jul 2017, at 9:54 am, Robert Bennett via swift-evolution > wrote: > > For expressions whose type is definitely non-optional, it makes sense to > verbally suggest both ! and ?? (and/or !! – was that accepted?), and it’s > probably best to insert ! when the

Re: [swift-evolution] Change default compiler fix for not-unwrapped Optional from ! To ?

2017-07-14 Thread Robert Bennett via swift-evolution
For expressions whose type is definitely non-optional, it makes sense to verbally suggest both ! and ?? (and/or !! – was that accepted?), and it’s probably best to insert ! when the fixit is accepted. For expressions whose type is undetermined, but which need some form of Optional handling, it

Re: [swift-evolution] Change default compiler fix for not-unwrapped Optional from ! To ?

2017-07-14 Thread Erica Sadun via swift-evolution
> On Jul 14, 2017, at 2:11 AM, Víctor Pimentel via swift-evolution > wrote: > >> On 14 Jul 2017, at 08:05, Rod Brown via swift-evolution >> wrote: >> >> >> >>> On 14 Jul 2017, at 2:36 pm, Robert Bennett via swift-evolution >>>

Re: [swift-evolution] Change default compiler fix for not-unwrapped Optional from ! To ?

2017-07-14 Thread Víctor Pimentel via swift-evolution
> On 14 Jul 2017, at 08:05, Rod Brown via swift-evolution > wrote: > > > >> On 14 Jul 2017, at 2:36 pm, Robert Bennett via swift-evolution >> wrote: >> >> When writing Swift code, it is not uncommon to forget to unwrap optionals. >>

Re: [swift-evolution] Change default compiler fix for not-unwrapped Optional from ! To ?

2017-07-13 Thread Félix Cloutier via swift-evolution
How should the fix-it transform the following code to make it valid? func foo(bar: String) -> Int func frob() -> String? func qaz() -> Int { return foo(bar: frob()) // frob() is optional, insert a ! to fix } > Le 13 juil. 2017 à 21:36, Robert Bennett via swift-evolution >

[swift-evolution] Change default compiler fix for not-unwrapped Optional from ! To ?

2017-07-13 Thread Robert Bennett via swift-evolution
When writing Swift code, it is not uncommon to forget to unwrap optionals. The compiler will offer a fixit, telling you you must insert either a ? or a !. However, when you accept the fixit, ! is inserted (at least, it is for me in Xcode 8.3). Ideally the fixit would default to ? because this