Closed theauk closed 1 month ago
Thanks for these reports! I'll take a look at them when I get a bit of free time.
In the mean time if you or anyone else wants to contribute fixes that'd be awesome!
Ok, looking into this, modifying an array you're iterating over is something that IMO non-broken code should not do, and because we're trying to target very constrained systems we don't have the flash/ram space or cycles to try and circumvent this, so I've just added comments to all the iterator functions pointing out that you might get non-spec-compliant behaviour.
Another similar issue was mentioned recently at https://github.com/espruino/Espruino/issues/2553 as well - was this a colleague?
Makes sense. And yes, https://github.com/espruino/Espruino/issues/2553 is from a colleague.
https://github.com/espruino/Espruino/commit/ff487e008472deff8113a32ebd3217dbd606405c
Test case
In steps:
Expected behavior I would expect
y
to become an array of length 2, so 1 would be logged at the end (from 2 / 2). It seems like an unexpectedundefined
is placed into the array, which makes its length 3, resulting in the logged 0.66. Running the test case on other JavaScript engines (Node, Hermes, and QuickJS), I get the expected 1.