Skip to content
Snippets Groups Projects
Commit 047e9d4f authored by Josh Meredith's avatar Josh Meredith :flag_au:
Browse files

JS: fix implementation of forceBool to use JS backend syntax

parent ec263a59
No related branches found
No related tags found
No related merge requests found
......@@ -639,7 +639,7 @@ jsResultWrapper result_ty
| Just (tc,_) <- maybe_tc_app, tc `hasKey` boolTyConKey = do
-- result_id <- newSysLocalDs boolTy
ccall_uniq <- newUnique
let forceBool e = mkJsCall ccall_uniq (fsLit "$r = !(!$1)") [e] boolTy
let forceBool e = mkJsCall ccall_uniq (fsLit "((x) => { return !(!x); })") [e] boolTy
return
(Just intPrimTy, \e -> forceBool e)
......
foreign import javascript "(($1) => { return $1; })"
bool_id :: Bool -> Bool
foreign import javascript "(($1) => { return !$1; })"
bool_not :: Bool -> Bool
foreign import javascript "(($1) => { console.log($1); })"
bool_log :: Bool -> IO ()
main :: IO ()
main = do
bool_log True
bool_log False
bool_log (bool_id True)
bool_log (bool_id False)
bool_log (bool_not True)
bool_log (bool_not False)
print (bool_id True)
print (bool_id False)
print (bool_not True)
print (bool_not False)
true
false
true
false
false
true
True
False
False
True
# These are JavaScript-specific tests
setTestOpts(when(not(js_arch()),skip))
test('T23101', normal, compile_and_run, [''])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment