Closed wereHamster closed 9 years ago
good point. keep in mind that you can only export lifted values though, these are always either a number, a boolean or a heap object. but this is indeed wrong, and a bit tricky to reproduce even.
I didn't have any trouble reproduce it ;)
main = withExport (0 :: Int) $ \r -> do
v <- derefExport r
print (v :: Maybe Int)
prints "Nothing".
It's easy to export the unevaluated version instead, and if GHC floats it to the top level it also becomes boxed again, and therefore truthy.
I've fixed it now and added it to the test case.
Int
prim type is represented as JavaScript integer, so this check inh$derefExport
wrongfully fails:Same problem with anything that is represented in JavaScript as a falsy value (
false
,undefined
, empty string).