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 Range#size return type to Int32 #14588

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

straight-shoota
Copy link
Member

@straight-shoota straight-shoota commented May 13, 2024

Resolves #14587

The super implementation Enumerable#size has the same type restriction already.

@straight-shoota
Copy link
Member Author

straight-shoota commented May 13, 2024

Hm, actually this can overflow on ranges of Int types that are bigger than Int32 🤔
Should we only cast to Int32 on smaller types?

@beta-ziliani
Copy link
Member

I'm afraid there's no good solution here. The good part of raising on overflow is that if it fits, it works. The bad part is that the failure is at runtime...

An alternative, as good or bad, is to statically fail on > Int32 types and have people do the math themselves 🤷

@straight-shoota straight-shoota changed the title Fix Rang#size return type to Int32 Fix Range#size return type to Int32 May 24, 2024
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.

Range#size returns an Union instead of an Int32
2 participants