-
-
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
simplify rules for mixed-signedness integer arithmetic (#9292) #23811
Conversation
- for different-size arguments, the larger type wins - otherwise the unsigned type wins
Oh wow, that was quick. Did you run the test suite locally? Were no code base changes required? |
Apparently tests pass and these cases just don't come up much (at least in Base). |
Sure, but https://github.com/JuliaLang/julia/pull/22482/files had to make a bunch of incidental changes so zero changes is actually impressive. I also suspect that's a very good sign about this particular rule – i.e. that it's usually what you want. Nice! |
Restarted the Circle CI x86_64 build but I suspect this is good. Further thoughts: the fact that this required zero changes suggests to me that people are already programming according to this rule intuitively; in cases where the old rules disagreed with the new one are cases where they were not sure what the rule was and probably wrote the code defensively with explicit conversions. I would further note that this doesn't just simplify the rule for mixed-signedness, it completely unifies the behavior for mixed or unmixed signedness (@JeffBezanson obviously already knows this since he wrote the tests in here that demonstrate the new, uniform behavior). |
Same segfault again; unrelated to this PR. |
I noticed that after this, |
Options that I can think of:
Option 3 seems best: just let signed integer types win in same-size, mixed signedness interactions. I think this is dictated by having platform-dependent signed literals but not unsigned ones. |
Oops – I'm not sure what I was doing here, these are the actual promotion tables: Unsigned wins (current):
Signed wins:
So either way there's one case where the promotion of some type (UInt32 or UInt64) with Int changes signedness based on the platform word size. |
This implements "option 5", from #9292 (comment):