If the argument of the function that rethrows is not marked as throws, then try is not needed. Here, condition is not marked as throws. The following works in both Silver and Xcode, but Xcode gives warning No calls to throwing functions occur within 'try' expression:
extension Swift.Array {
#if ELEMENTS
typealias Element = T
#endif
func `where`(_ condition: ((Element) -> Bool)) -> [Int] {
let filtered = try! self.enumerated().filter({ condition($0.1) }) // Xcode warns for unnecessary try
return filtered.map({ $0.0 })
}
}
Any chance you can re-create/illustrate this issue with a simple test-case that does not depend on SBL or LINQ? I.e. just a function you declare yourself and a call to it, that shows the problem?
The above was with Toffee V1. With Toffee V2, I get another set of errors (this time including the one for which I was trying to add the test):
func without_throw() -> Int {
return 0
}
func with_throw() throws -> Int {
return 0
}
public func test(_ arg: (() throws -> Int)) rethrows -> () {
let _ = try! arg()
return
}
// These all work with Apple's compiler:
test(without_throw) // E: Parenthesis required for call
try! test(with_throw) // E: Parenthesis required for call
test { return 0 } // E: "try" required for call to "func ConsoleApplication.test(_ arg: () -> Int throws)
// This gives warning with Apple's compiler:
try! test { return 0 } // Works in Silver
print("pass")