Rewrite 7.b.i and 7.b.ii to not overflow integer range
Opened this issue · 1 comments
sno2 commented
The current steps use a unique way of checking for overflows:
i. Set count to count + 1.
ii. If count ≥ 2**53, then (...)
This compares count
to a value outside of the valid integer range. I believe the spec has explicitly avoided defining comparisons with integer outside of the range as shown in the following examples:
- https://tc39.es/ecma262/#sec-groupby (See 6.a)
- https://tc39.es/ecma262/#sec-number.issafeinteger (See 1.a)
- https://tc39.es/ecma262/#sec-advancestringindex (See 1)
- https://tc39.es/ecma262/#sec-array.from (See 5.e.i)
- https://tc39.es/ecma262/#sec-array.prototype.concat (5.b.ii)
- ... a few more usages of
2**53 - 1
I think it would be better to swap these instructions with this:
i. If count >= 2**53 - 1, then (...)
ii. Set count to count + 1.
which would avoid a value of count
outside of the integer range. Thanks for the proposal.
sno2 commented
Would this change be better as a PR?