Exhaustiveness Checker does not consider bound identifiers in tuples in checks

Originator:widmannrobert
Number:rdar://21892845 Date Originated:19-Jul-2015
Status:Open Resolved:
Product:Developer Tools Product Version:7.0 Beta 3
Classification: Reproducible:Always
 
Summary:
When an identifier is bound in a case-let expression the exhaustiveness checker does not appear to consider it covered as in

func op(this : Optional<Bool>, other : Optional<Bool>) -> Optional<Bool> {
	switch (this, other) {
	case let (.None, w):
		return w
	case let (w, .None):
		return w
	case let (.Some(e1), .Some(e2)):
		return .Some(e1 && e2)
	} // cases are non-exhaustive, consider adding default clause
}

Despite such a definition being acceptable in languages like ML and Haskell.  However, when the case-lets are changed to simple cases the exhaustiveness checker stops complaining about the same expression.

func op(this : Optional<Bool>, other : Optional<Bool>) -> Optional<Bool> {
	switch (this, other) {
	case (.None, _):
		return .None
	case (_, .None):
		return .None
	case let (.Some(e1), .Some(e2)):
		return .Some(e1 && e2)
	} // All clear
}

The checker should consider tuple expressions with identifiers bound in case-lets as wildcards in plain cases.

Steps to Reproduce:
1. Declare both of those functions in a playground.

Expected Results:
The exhaustiveness checker reports both as exhaustive.

Actual Results:
The exhaustiveness checker rejects the former and accepts the latter.

Version:
Xcode 7.0 beta 3 (7A152u)

Notes:


Configuration:


Attachments:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!