diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-06-20 13:40:13 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-06-23 14:11:14 -0400 |
commit | 1faf4982e26dc89d5e9d68810e0d764596587fdd (patch) | |
tree | 10cc38f577a35c00684a74f35b551b527938b7b5 | |
parent | 1f2fff89afebb065b27eba0f6e1f89e25c1c158d (diff) | |
download | haskell-1faf4982e26dc89d5e9d68810e0d764596587fdd.tar.gz |
testsuite: Add test for #16846
-rw-r--r-- | testsuite/tests/codeGen/should_run/T16846.hs | 37 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/T16846.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_run/all.T | 1 |
3 files changed, 42 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/T16846.hs b/testsuite/tests/codeGen/should_run/T16846.hs new file mode 100644 index 0000000000..af961fe681 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T16846.hs @@ -0,0 +1,37 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE ExistentialQuantification #-} +module Main (main) where + +import Control.Concurrent.STM + +data Free f a = Pure a | Free (f (Free f a)) + +data SuspendF a + = forall r. StepSTM (STM r) + | forall r. StepIO (IO r) + +effect :: STM a -> Free SuspendF a +effect a = Free $ StepSTM a + +io :: IO a -> Free SuspendF a +io a = Free $ StepIO a + +comb :: [Free SuspendF a] -> Free SuspendF a +comb vs = io $ do + _ <- mapM go vs + undefined + +go :: Free SuspendF a -> IO (STM ()) +go (Free (StepIO a)) = a >>= \_ -> go $ Pure undefined +go (Free (StepSTM a)) = pure $ a >>= \_ -> pure () +go (Pure _) = pure $ pure () + +runWidget :: Free SuspendF a -> IO a +runWidget w = case w of + Free (StepIO io) -> do + _ <- io + undefined + +-- Uncommenting this hid the original bug. +--main :: IO () +main = runWidget $ comb $ replicate 10000000 (effect retry) diff --git a/testsuite/tests/codeGen/should_run/T16846.stderr b/testsuite/tests/codeGen/should_run/T16846.stderr new file mode 100644 index 0000000000..f737c83af0 --- /dev/null +++ b/testsuite/tests/codeGen/should_run/T16846.stderr @@ -0,0 +1,4 @@ +T16846: Prelude.undefined +CallStack (from HasCallStack): + error, called at libraries/base/GHC/Err.hs:80:14 in base:GHC.Err + undefined, called at T16846.hs:22:3 in main:Main diff --git a/testsuite/tests/codeGen/should_run/all.T b/testsuite/tests/codeGen/should_run/all.T index 535ca8651e..20ac9cc59e 100644 --- a/testsuite/tests/codeGen/should_run/all.T +++ b/testsuite/tests/codeGen/should_run/all.T @@ -197,3 +197,4 @@ test('T15892', compile_and_run, ['-O']) test('T16617', normal, compile_and_run, ['']) test('T16449_2', exit_code(0), compile_and_run, ['']) +test('T16846', [only_ways(['optasm']), exit_code(1)], compile_and_run, ['']) |