-
-
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
Fix for last{T}(t::Range{T}) #2734
Conversation
* Because of automatic promotion of small integer types to Int/Uint, last(t::Range) was a different type than start(t). This commit fixes that.
Seems sane to me. @JeffBezanson? |
Slightly more info: what prompted this was julia> uint16(1):uint16(10)
0x0001:0x000000000000000a which, after the commit, becomes the more expected julia> uint16(1):uint16(10)
0x0001:0x000a |
The problem is a bit more extensive than this. Everything I'm starting to question our integer arithmetic again; it has caused a few surprises, and has the potential to generate type-unstable loops even when all inputs are the same type. |
That's unfortunate, but I have to say, it's been a long time since I've encountered an unpleasant surprise and I tend to find that it just does what I want, which is nice. We could also just implement henchmen unrolling. |
We need henchmen unrolling anyway, so the problem is more the first part, that you need |
I think something much deeper is wrong with the range stuff and was working on a fix, but doing anything with ranges is brutal because it's so deep in the language and if anything goes wrong you're toast. In any case, I think it's safe to merge this. Was just pinging you since you did the most recent major surgery on ranges. |
Is there something else to fix in ranges besides the floating point accuracy thing? |
The current state just feels pretty ugly and changing it to accommodate the floating-point accuracy thing is kind of hard given the way it currently works. |
Well at least now we can remove |
That would certainly be an improvement. |
Fix for last{T}(t::Range{T})
Int
/Uint
,last(t::Range)
was a different type thanstart(t)
.This commit fixes that.