Details
-
Type:
Bug
-
Status: Resolved
-
Priority:
Medium
-
Resolution: Done
-
Component/s: Compiler
-
Labels:
-
Environment:
Xcode 7.3.1, Toolchain: Swift Development Snapshot 2016-05-31 (a)
Description
Consider the following code:
class ViewController: UIViewController { func test() { // no warning self.navigationController?.pushViewController(UIViewController(), animated:false) // warning self.navigationController?.popViewController(animated:false) } }
The first line causes no warning. The second line causes a warning, "Expression of type 'UIViewController?' is unused."
Of course I understand why this is, in theory. The second call returns a value, and I am ignoring it. But from a practical point of view, to ignore this value is normal behavior, so the warning is just annoying (i.e. it isn't helpful). I can work around the problem by assigning the second line to an unnamed variable:
_ = self.navigationController?.popViewController(animated:false)
But this seems like a bit much. I'm ending up with my code peppered with that sort of expression; it's kind of ugly.