{"action":"created","issue":{"url":"https://api.github.com/repos/ghcjs/ghcjs/issues/307","labels_url":"https://api.github.com/repos/ghcjs/ghcjs/issues/307/labels{/name}","comments_url":"https://api.github.com/repos/ghcjs/ghcjs/issues/307/comments","events_url":"https://api.github.com/repos/ghcjs/ghcjs/issues/307/events","html_url":"https://github.com/ghcjs/ghcjs/issues/307","id":58441918,"number":307,"title":"FFI passes unevaluated thunk to JavaScript","user":{"login":"ryantrinkle","id":1156448,"avatar_url":"https://avatars.githubusercontent.com/u/1156448?v=3","gravatar_id":"","url":"https://api.github.com/users/ryantrinkle","html_url":"https://github.com/ryantrinkle","followers_url":"https://api.github.com/users/ryantrinkle/followers","following_url":"https://api.github.com/users/ryantrinkle/following{/other_user}","gists_url":"https://api.github.com/users/ryantrinkle/gists{/gist_id}","starred_url":"https://api.github.com/users/ryantrinkle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryantrinkle/subscriptions","organizations_url":"https://api.github.com/users/ryantrinkle/orgs","repos_url":"https://api.github.com/users/ryantrinkle/repos","events_url":"https://api.github.com/users/ryantrinkle/events{/privacy}","received_events_url":"https://api.github.com/users/ryantrinkle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-21T04:27:18Z","updated_at":"2015-03-03T20:39:44Z","closed_at":null,"body":"The following program should produce 3 checkboxes: `[ ]  [X]  [ ]`.  It does this correctly under GHC and under GHCJS with -O1 or -O2.  However, under GHCJS with -O0, it produces `[ ] [X] [X]`.  This appears to be due to an unevaluated thunk being passed into JavaScript via htmlInputElementSetChecked.  Since the thunk is an object, it is \"truthy\" in JavaScript.\r\n\r\n```haskell\r\nimport GHCJS.DOM\r\nimport GHCJS.DOM.Element\r\nimport GHCJS.DOM.Document\r\nimport GHCJS.DOM.HTMLInputElement\r\nimport GHCJS.DOM.Node\r\nimport GHCJS.DOM.Types hiding (Event)\r\n\r\nmain :: IO ()\r\nmain = runWebGUI $ \\webView -> do\r\n  Just doc <- fmap (fmap castToHTMLDocument) $ webViewGetDomDocument webView\r\n  Just body <- documentGetBody doc\r\n  let testCheckbox x = do\r\n        Just e <- fmap (fmap castToHTMLInputElement) $ documentCreateElement doc \"input\"\r\n        elementSetAttribute e \"type\" \"checkbox\"\r\n        htmlInputElementSetChecked e x\r\n        _ <- nodeAppendChild body $ Just e\r\n        return ()\r\n  testCheckbox False\r\n  testCheckbox True\r\n  testCheckbox $ id False\r\n```"},"comment":{"url":"https://api.github.com/repos/ghcjs/ghcjs/issues/comments/77029656","html_url":"https://github.com/ghcjs/ghcjs/issues/307#issuecomment-77029656","issue_url":"https://api.github.com/repos/ghcjs/ghcjs/issues/307","id":77029656,"user":{"login":"luite","id":354096,"avatar_url":"https://avatars.githubusercontent.com/u/354096?v=3","gravatar_id":"","url":"https://api.github.com/users/luite","html_url":"https://github.com/luite","followers_url":"https://api.github.com/users/luite/followers","following_url":"https://api.github.com/users/luite/following{/other_user}","gists_url":"https://api.github.com/users/luite/gists{/gist_id}","starred_url":"https://api.github.com/users/luite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luite/subscriptions","organizations_url":"https://api.github.com/users/luite/orgs","repos_url":"https://api.github.com/users/luite/repos","events_url":"https://api.github.com/users/luite/events{/privacy}","received_events_url":"https://api.github.com/users/luite/received_events","type":"User","site_admin":false},"created_at":"2015-03-03T20:39:44Z","updated_at":"2015-03-03T20:39:44Z","body":"hm, this does not happen on GHCJS compiled with GHC 7.10"}}