-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Range#size returns an Union instead of an Int32 #14587
Comments
Quoting PR comments to bring the general discussion back here: @straight-shoota #14588 (comment)
@beta-ziliani #14588 (comment)
That's also not good because I think casting to We'll eventually need to increase that size type in order to support bigger collections. But while
I think we should explain that caveat explicitly in the API docs and that's it. We should however consider adding an alternative method that unconditionally returns |
But how would this work if the range is exclusive? I'm thinking that the only reason why the untyped |
Of course I don't follow what you mean in the rest of the comment about the type of |
If you do: if bla
0
else
a - b
end the result is the union of |
Okay, gotcha. But the problem is not the union alone. Returning anything but So there's no point in converging the return type on (having |
@beta-ziliani We can do {% if B < Int && E < Int %}
...
n < 0 ? typeof(n).zero : n
{% else %}
...
{% end %} The return type of I think |
ah yes, when I wrote this comment I was aware of the problem with the interface in |
TBH: I'm not sure which solution is best. I think both choices have pros and cons: |
IMO there is no choice. The return type of any implementation of |
The following snippet:
returns
instead of the expected
The text was updated successfully, but these errors were encountered: