Closed wereHamster closed 7 years ago
hmm, that's not ok. it looks like the Int
is treated as an IO Int
Think I've found the problem
https://github.com/ghcjs/ghcjs-base/blob/master/GHCJS/Foreign/Export.hs#L69
This line is wrong (or the foreign import is)
should be fixed with 05d8df85e7202320c5bcecb53596aa1a99266472
Is there a way to use ghcjs-base directly from the git repo? Or do I have to wait until you make another release?
You can just cabal install ghcjs-base as any normal package. If you want to make sure that the updated version is used, just bump the version number and add a constraint to your project.
Doesn't seem to be fixed yet. Still getting the exception when the RTS tries to access f
property on a number (the 424242424242).
Ok, I'll look into this again. Admittedly I hadn't tested it.
Ack, missing Just
, I'm too used to the type system catching things like this for me. I shouldn't take risks around unsafeCoerce
:)
fixed it here and have a test case, will push later tonight when i have some other things cleaned up.
I'm not sure if this is the same issue or not, but it seems related:
I've got a function:
patch :: Typeable a => Node -> a -> (a -> IO ()) -> IO ()
patch n x f = do
xRef <- export x
cb <- syncCallback1 ThrowWouldBlock $ \ref -> do
(Just xVal) <- derefExport ref
f xVal
js_patch n cb xRef
releaseCallback cb
releaseExport xRef
When I call it with pretty much any value I've tried so far as the value of a
, I get the exception h$ap_1_0_fast: unexpected closure type: 2
I haven't been able reproduce this with the latest version of shims and ghcjs-base. can you make a runnable example that does this?
It appears to be fixed now that I'm running on master for both, but it seems like there's no longer a way to convert from JSVal -> Export a
without an unsafeCoerce AFAICT. Am I missing something?
it seems like there's no longer a way to convert from JSVal -> Export a without an unsafeCoerce AFAICT. Am I missing something?
I think that is intentional. In normal usage you would Export a
as the return value of a jsffi (so no coercing is needed):
foreign import javascript "getTheStoredExport()" getTheStoredExport :: IO (Export a)
I was expecting this to print
Just 424242424242
. Instead it throws a RTS exception.The problem appears to be that the heap object
root
is the integer, whileh$ap_1_0_fast
expects it to be an object with af
property.