-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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(0, length=Uint(0)) throws InexactError #35711
Comments
So, problem seems to stem from promotion of Int -> UInt (which then underflows) on Line 107 in 84d7e67
Possible fix _range(a::Real, ::Nothing, ::Nothing, len::Integer) = UnitRange{typeof(a)}(a, a+oftype(a, len)-1) |
This is strongly related to #10554; we should figure out a way to do the promotion that solves both cases (the MWE for that one is now |
At least julia> range(UInt(0),length=0)
0x0000000000000000:0xffffffffffffffff julia> range(2,length=typemax(Int64))
2:1 Though, surely there is some responsibility of the caller to ensure the datatypes used don't overflow/underflow (unless |
…pplicable) (JuliaLang#43059) Be careful to use `oneunit` instead of `1`, so that arithmetic on user-given types does not promote first to Int. Fixes JuliaLang#35711 Fixes JuliaLang#10554
…pplicable) (JuliaLang#43059) Be careful to use `oneunit` instead of `1`, so that arithmetic on user-given types does not promote first to Int. Fixes JuliaLang#35711 Fixes JuliaLang#10554
Due to the fact that empty ranges are represented by n:n-1, which breaks with n=0 and unsigned types.
I think the
range
expression is a valid one that ought to be supported and the error message is not very helpful.Could not find anything related on discourse, the closest one is:
#26608
The text was updated successfully, but these errors were encountered: