Normative: use Numbers instead of reals as counters in Iterator builtins#3776
Normative: use Numbers instead of reals as counters in Iterator builtins#3776michaelficarra wants to merge 3 commits intomainfrom
Conversation
|
The rendered spec preview for this PR is available as a single page at https://tc39.es/ecma262/pr/3776 and as multiple pages at https://tc39.es/ecma262/pr/3776/multipage . |
|
In #2007 we discussed the issue of counters and IIRC agreed that we should specify them as mathematical values with the understanding that implementations would diverge in the same way they diverge from the requirements to have arbitrarily large strings and callstacks and similar. I think that's better than this. |
|
Even JSSE, the entirely AI-generated engine, gets this wrong: https://github.com/pmatos/jsse/blob/main/src/interpreter/builtins/iterators.rs. I guess it didn't read the spec... |
56466b4 to
a5e3a69
Compare
|
(When I tried to suggest this on the 'changes' page, GitHub acted weird:) |
|
Oh, thank you @jmdyck! |
60065a8 to
20e6fb7
Compare
All known engines are currently non-compliant. If they use Numbers as counters today, they'll stop advancing at 253. So counters passed to user-provided callbacks will always be 253 once they reach that point and take/drop will behave as if Infinity was passed. With this change, internal counters are now Numbers, so the argument passed to user-provided callbacks is expected to repeat at 253 (matching implementations today). In addition, take/drop throw a RangeError on finite inputs ≥ 253.
See tc39/proposal-iterator-includes#12 for context.