counting and summing Bools with a small integer init promote to Int - #58374
Conversation
for accumulate inference
|
OK, so upon reflection here, I think we should just always promote all small integers to |
init promote to [U]Intinit promote to Int
|
@nanosoldier |
|
The package evaluation job you requested has completed - possible new issues were detected. Report summary❗ Packages that crashed2 packages crashed on the previous version too. ✖ Packages that failed14 packages failed only on the current version.
1240 packages failed on the previous version too. ✔ Packages that passed tests25 packages passed tests only on the current version.
5370 packages passed tests on the previous version too. ~ Packages that at least loaded11 packages successfully loaded only on the current version.
2975 packages successfully loaded on the previous version too. ➖ Packages that were skipped altogether920 packages were skipped on the previous version too. |
|
I think so the promotion proposed here would fall out of that and makes sense to me |
|
Triage thinks this is clearly a good idea. |
|
Should we do this with |
That's a very good question. I had initially dismissed it without much thought because, well, multiplying by booleans doesn't do much. In fact, there's no need for a widening at all, because the booleans multiply with other types as either their But we still have the same (potential) type instability when combining multiple intermediate results as above. |
This is a small but concrete and independent change that can easily be split out from #58241 and is required for more pairwise reassociations (like #52397).
Specifically, it's required because
countandsumuseBase.add_sum, which very intentionally promotes small integers toIntorUint. And if you add twoBools together, they also promote toInt. But if aninit=0x00is provided, then we get into a strange situation. This is the status quo on master right now:In other words, if we happen to choose to re-associate the branches here, we end up with a
0x02 +ₛ 0x02, which promotes toUint.This change here adds
Boolinto the extra promotion behaviors foradd_sum. So with this commit, the above session becomes: