ghcjs / ghcjs-base

base library for GHCJS for JavaScript interaction and marshalling, used by higher level libraries like JSC
MIT License
45 stars 67 forks source link

Fix invalid unsafeCoerce usage #70

Closed iand675 closed 7 years ago

iand675 commented 8 years ago

js_listProps was improperly treating a JSArray as [JSString], which was causing crashes trying to use the FromJSVal instance for Value. @luite This seems like a fairly serious bug rather than just a nicety. Any chance this can get reviewed & merged ASAP?

wuzzeb commented 7 years ago

Unfortunately, while this is a temporary fix, it doesn't fix the underlying problem which is that there are two versions of the h$listProps function, one which returns a haskell value for which unsafeCoerce works perfectly fine in ghcjs-base's jsbits, and one which returns a javascript list located in shims which breaks the unsafeCoerce.

Since the order that ghcjs emits code is causing it to select the one from shims, your change to use fromListIO does work. But if ghcjs ever changes the order in which code is emitted, this will break again and have to go back to unsafeCoerce.

The solution is to rename one of the two versions of h$listProps. I would submit a pull, but I don't know exactly why the shims version of h$listProps even exists. Maybe the correct solution is to just delete the version of h$listProps inside shims? As far as I can see, nothing in shims itself requires h$listProps.

hamishmack commented 7 years ago

This should have been fixed by https://github.com/ghcjs/shims/pull/41