From 3457df9993a78e408ed56f0bb619941911d375d0 Mon Sep 17 00:00:00 2001 From: Nathan Faubion Date: Tue, 17 Apr 2018 20:33:42 -0700 Subject: [PATCH] Fix 'bhead is not a function' for forks (#145) --- src/Control/Monad/Aff.js | 4 ++-- test/Test/Main.purs | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Control/Monad/Aff.js b/src/Control/Monad/Aff.js index a46fa18..1689250 100644 --- a/src/Control/Monad/Aff.js +++ b/src/Control/Monad/Aff.js @@ -372,7 +372,7 @@ var Aff = function () { break; case FORK: - status = STEP_BIND; + status = STEP_RESULT; tmp = Fiber(util, supervisor, step._2); if (supervisor) { supervisor.register(tmp); @@ -380,7 +380,7 @@ var Aff = function () { if (step._1) { tmp.run(); } - step = tmp; + step = util.right(tmp); break; case SEQ: diff --git a/test/Test/Main.purs b/test/Test/Main.purs index 81583cd..223113e 100644 --- a/test/Test/Main.purs +++ b/test/Test/Main.purs @@ -634,7 +634,7 @@ test_scheduler_size = assert "scheduler" do eq 100000 <$> readRef ref test_lazy ∷ ∀ eff. TestAff eff Unit -test_lazy = assert "Lazy Aff" do +test_lazy = assert "lazy" do varA ← makeEmptyVar varB ← makeEmptyVar fiberA <- forkAff $ fix \loop -> do @@ -653,6 +653,13 @@ test_lazy = assert "Lazy Aff" do putVar 0 varA eq "done" <$> joinFiber fiberB +test_regression_return_fork ∷ ∀ eff. TestAff eff Unit +test_regression_return_fork = assert "regression/return-fork" do + bracket + (forkAff (pure unit)) + (const (pure unit)) + (const (pure true)) + main ∷ TestEff () Unit main = do test_pure @@ -698,3 +705,4 @@ main = do -- Turn on if we decide to schedule forks -- test_scheduler_size test_parallel_stack + test_regression_return_fork