New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-2559] EXC_BAD_ACCESS when comparing two optionals #45164
Comments
The |
Comment by Eric (JIRA) Oh! Of course. I'm sure there's a way to check for nil without using `== nil` but that didn't even occur to me. |
A related enhancement request here would be something like Clang's -Winfinite-recursion: we have a call to the containing function here that happens on all paths. |
You can check for nil by using |
Generally the "right" way to implement this is to make Car conform to Equatable, define the "func ==" for Cars, and then for optionals let the generic form of "func ==" for optionals of Equatables kick in. I think a warning like -Winfinite-recursion would be a fine idea, though. |
Comment by Eric (JIRA) Yeah, that would work great Mark. I stumbled on this because I was trying to implement this for a `typealias` on a tuple, so I (didn't think I could) make it conform to Equatable. Didn't want to include that complexity in the example though. |
Resolved by the merge of #11869. |
Environment
Version 8.0 beta 5 (8S193k)
Additional Detail from JIRA
md5: 3347db583ab3a5058e6686a7c2f8a53b
relates to:
Issue Description:
I have a reproducible crash in playground environment.
The formatting here is bad, so you can see the code here: https://gist.github.com/SimplGy/934af7b6bd43b1296a4fa168fd2137bc
Or it is below for completeness.
No Runtime Error:
Runtime error:
The text was updated successfully, but these errors were encountered: