13:11 | <jschoi> | i meant May 6 9:00 - 10:00 PT, 1 hour later |
22:14 | <ljharb> | Array(Math.pow(2, 32) - 1).concat(1) throws a RangeError about "too large" in node; in Safari it throws an OOM RangeError; in FF it seems to just hang. the spec seems to say it should throw a TypeError (https://tc39.es/ecma262/#sec-array.prototype.concat step 5.b.iii). am i reading it right? if so i can make a test262 test for it. |
22:22 | <shu> | that's not my reading |
22:23 | <shu> | OOMs are implementation-defined and can really happen anywhere. the spec says a TypeError should be thrown for lengths that exceed that value, even without an implementation-defined OOM error |
22:23 | <shu> | so Safari is certainly allowed to throw an OOM |
22:23 | <shu> | as for FF hanging, that's fine too, i think, from a compliance perspective |
22:24 | <shu> | it might be undesirable to hang, but i don't think that's breaking compliance with the spec |
22:25 | <shu> | a test262 here test can test that either a TypeError or an OOM RangeError is thrown, i'd think |
22:25 | <shu> | actually i'm not sure implementation-defined OOM errors are required to be RangeError s or can be anything |
22:25 | <shu> | so maybe the test is just that it must throw something |
22:33 | <ljharb> | oh the OOM part and the hanging part yes, ofc |
22:34 | <ljharb> | but chrome/node doesn't throw an OOM - it throws a RangeError with a message. but the spec says it should be a TypeError |
22:34 | <ljharb> | thinking about it, it should really just be a RangeError anyways. so maybe it'd be a better web reality change to change the spec? |
22:34 | <shu> | hm, maybe, agreed that it feels like a rangeerror |
22:35 | <shu> | i feel like OOMs and resource limit-related errors are usually Range, not Type |
22:40 | <shu> | seems like all the array methods throw TypeError for > 2^53 - 1 |
22:40 | <shu> | but ljharb, V8/node does throw an OOM |
22:40 | <ljharb> | hm |
22:40 | <shu> | it's throwing on trying to create an array with length > 2^32 - 1 |
22:41 | <shu> | not throwing on a length > 2^53 - 1 |
22:41 | <ljharb> | in node 18 i get Uncaught RangeError: Invalid array length |
22:41 | <shu> | yeah |
22:41 | <ljharb> | ohhh i see what you mean |
22:41 | <shu> | it throws before it gets to the check for typeerror |
22:41 | <ljharb> | [1].concat({ length: Math.pow(2, 53) - 1, [Symbol.isConcatSpreadable]: true }) indeed does throw a TypeError |
22:41 | <shu> | or, no, it just doesn't hit that |
22:41 | <shu> | yeah |
22:42 | <ljharb> | thanks, that clears it up |