On Mar 18, 2016, at 11:36 AM, Chris Willmore via swift-evolution <[email protected]> wrote: >> typedef void (^CallbackBlock)(FDataSnapshot *snapshot); >> >> The parameter in the block gets converted into a IUO, I ended up releasing >> an app that crashed due to that IUO being nil. >> >> The code that crashed was something like this >> >> object.observe { >> $0.doSomething() >> } >> >> There is no way to tell that the $0 was a IUO. The compiler didn't force me >> to confirm in it in some way using a ! and unless I remembered to check the >> header I would have a crash. >> >> How would this work under your proposal ? > > This is a great question. I think it would make the most sense to import the > CallbackBlock type as (FDataSnapshot?) -> (), since there’s no decl to hang > the IUO attribute onto. Then $0 ends up with type FDataSnapshot? (i.e. > Optional<FDataSnapshot>), and the compiler would not allow you to simply call > doSomething() on $0 without forcing it first.
I agree that this is the most straight-forward thing to do. Chris, please add a mention of this to the proposal so that the review discussion considers it. Thanks! -Chris
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
