You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-487 Compiler fails to consider @autoclosure when satisfying try requirements
Issue Description:
The compiler returns false error when giving an @autoclosure parameter that could throw.
See projet in attachement, the bug is illustrated in SampleTests/SampleSpec.swift.
importQuickimportNimble@testableimportSampleclassSampleSpec: QuickSpec {
overridefuncspec() {
describe("what looks like a bug") {
// this version does not compileletclosureWithoutCatch = {
letobject = MyClass()
// expect takes an @autoclosure as its first parameterexpect(tryobject.functionThatThrow()).to(throwError())
}
// swiftc: Invalid conversion from throwing function of type '() throws -> ()' to non-throwing function type '() -> Void'it("generates a compiler error", closure: closureWithoutCatch)
// this version compile but emits a warning that makes no sense considering the previous errorletclosureWithCatch = {
letobject = MyClass()
do {
expect(tryobject.functionThatThrow()).to(throwError())
} catch {
// swiftc: 'catch' block is unreachable because no errors are thrown in 'do' block
}
}
it("generates a compiler warning", closure: closureWithCatch)
// with a func the compiler raises no warning nor errorit("just works", closure: closureAsFunc)
}
}
funcclosureAsFunc() {
letobject = MyClass()
expect(tryobject.functionThatThrow()).to(throwError())
}
}
The text was updated successfully, but these errors were encountered:
Attachment: Download
Environment
Mac OS Sierra 10.12.2 (16C67)
Xcode 8.3 (8E162)
Additional Detail from JIRA
md5: 7f09d8ea61b526e97fbbd84ca56b5f2c
duplicates:
Issue Description:
The compiler returns false error when giving an @autoclosure parameter that could throw.
See projet in attachement, the bug is illustrated in SampleTests/SampleSpec.swift.
The text was updated successfully, but these errors were encountered: