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

Fix Enum#includes? to require all bits set #13229

Merged

Conversation

straight-shoota
Copy link
Member

The implementation of Enum#includes? is too lax and returns true if any common bit is set (#13160 (comment)). This patch checks that all bits are set.

@HertzDevil Suggested this might need to be merged together with #13160, but I would see it as fix that makes sense on its own. We can pool them together, but I don't think it's strictly necessary...?

The behaviour of None may need some explanation. The current implementation always returns false when the parameter is None (even for None.includes?(None)). Some code may depend on this quirk, including the implementation of Enum.each (hence this needed to be fixed as well).
I wouldn't expect much code to be affected and it's probably best to apply this change regardless. It is a bug and fixing it may have a small chance of breaking someone's code.

@straight-shoota straight-shoota added this to the 1.8.0 milestone Mar 28, 2023
@straight-shoota straight-shoota merged commit 600a533 into crystal-lang:master Mar 29, 2023
@straight-shoota straight-shoota deleted the fix/enum-includes branch March 29, 2023 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants