nuprl / Stopify

A JS-to-JS compiler that makes it easier to build Web IDEs and compile to JS.
https://zenodo.org/records/10408254
BSD 3-Clause "New" or "Revised" License
173 stars 12 forks source link

Array.flat and Array.flatMap not handled correctly by @stopify/higher-order-functions #472

Closed jjbarr closed 3 years ago

jjbarr commented 4 years ago

Neither Array.prototype.flat nor Array.prototype.flatMap are handled correctly by @stopify/higher-order-functions. To be more precise, as far as I can tell, they're not handled at all. If a user calls either function, they are handed back a raw array, not hooked by stopifyArray, which is obviously a Bad Thing, and can lead to confusing error messages in Ocelot. Once an array is touched by either function, it is "infected": you can't really very easily get a "cooked" array back.

This is really a problem with any method in Array.prototype that returns an array which we don't patch (I think the abstraction is essentially destined to leak), but Array.flat and Array.flatMap sting in particular, as they're fairly commonly used.

arjunguha commented 4 years ago

Thanks for pointing this out. It will be an easy fix. However, it may not be deployed in Ocelot until after the end of semester

arjunguha commented 3 years ago

Fixed in 0.7.3. Should be in Ocelot soon.