Skip to content
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

Add rule for ?? nil #764

Closed
jpsim opened this issue Aug 21, 2016 · 6 comments
Closed

Add rule for ?? nil #764

jpsim opened this issue Aug 21, 2016 · 6 comments

Comments

@jpsim
Copy link
Collaborator

jpsim commented Aug 21, 2016

This is always redundant as the rhs of the nil coalescing operator is only ever evaluated if the lhs is nil. This should really be a warning in the Swift compiler...

@daniel-beard
Copy link
Contributor

I'd like to take this one on. Working on it now.

@jpsim
Copy link
Collaborator Author

jpsim commented Aug 24, 2016

Hmmm, actually there are cases where this is valid, for example when lhs is a double optional: Optional<Optional<T>>. Maybe we shouldn't make such a rule. Or if we do, it should be a warning & opt-in.

@daniel-beard
Copy link
Contributor

I'll make it an opt-in rule for now

@BluMist
Copy link

BluMist commented Sep 4, 2016

nitpick: I believe coalesing should be changed to coalescing, you actually spelled it correctly once in the description

description: "nil coalescing operator is only evaluated if the lhs is nil " + ", coalesing operator with nil as rhs is redundant",

@marcelofabri
Copy link
Collaborator

This was implemented in #773 and could be closed

@norio-nomura
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants