> This is a warning right now — do you think it should be an error?
> 
> Slavas-MacBook-Pro:~ slava$ cat ttt.swift 
> func f() {}
> 
> func g() {
>  try f()
>  try? f()
> }
> 
> Slavas-MacBook-Pro:~ slava$ swiftc ttt.swift 
> ttt.swift:4:3: warning: no calls to throwing functions occur within 'try' 
> expression
>  try f()
>  ^
> ttt.swift:5:8: warning: no calls to throwing functions occur within 'try' 
> expression
>  try? f()
>       ^

IMHO at least, this should be an error. As a side note I do think that try 
should have greater precedence than as, even though this does potentially limit 
calls that would use only one try on a series of throwing statement that can be 
handled using parentheses. The benefit is that try is probably called in the 
vast majority of situations (that’s my experience at least) on a single throw 
statement and having it have higher precedance would avoid some surprises as 
most developers probably already assume that try wil be executed before as.

— Davor
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to