summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-02-21 19:26:51 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-04 23:15:12 -0500
commitc6ec7f4868cd7b22869f559de23acd3245639c68 (patch)
treea61b92a6efd5c2ac29473acd02eb9e8b7524b78b
parente679321e859d2acad2248249efaab9bf1c13521b (diff)
downloadhaskell-c6ec7f4868cd7b22869f559de23acd3245639c68.tar.gz
testsuite: Add test for #19413
This was fixed as a result of #19181.
-rw-r--r--testsuite/tests/simplCore/should_run/T19413.hs17
-rw-r--r--testsuite/tests/simplCore/should_run/T19413.stdout2
-rw-r--r--testsuite/tests/simplCore/should_run/all.T1
3 files changed, 20 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_run/T19413.hs b/testsuite/tests/simplCore/should_run/T19413.hs
new file mode 100644
index 0000000000..65727e4e76
--- /dev/null
+++ b/testsuite/tests/simplCore/should_run/T19413.hs
@@ -0,0 +1,17 @@
+{-# OPTIONS_GHC -O1 #-}
+
+import System.IO.Unsafe
+import Data.IORef
+
+{-# NOINLINE resourceId #-}
+resourceId :: IO Int
+resourceId = unsafePerformIO counter
+
+counter :: IO (IO Int)
+counter = do
+ ref <- newIORef 0
+ pure $ atomicModifyIORef' ref $ \i -> let j = i + 1 in (j, j)
+
+main = do
+ print =<< resourceId
+ print =<< resourceId
diff --git a/testsuite/tests/simplCore/should_run/T19413.stdout b/testsuite/tests/simplCore/should_run/T19413.stdout
new file mode 100644
index 0000000000..1191247b6d
--- /dev/null
+++ b/testsuite/tests/simplCore/should_run/T19413.stdout
@@ -0,0 +1,2 @@
+1
+2
diff --git a/testsuite/tests/simplCore/should_run/all.T b/testsuite/tests/simplCore/should_run/all.T
index afedee6bcc..a6458ee311 100644
--- a/testsuite/tests/simplCore/should_run/all.T
+++ b/testsuite/tests/simplCore/should_run/all.T
@@ -97,3 +97,4 @@ test('NumConstantFolding8', normal, compile_and_run, [''])
test('NumConstantFolding16', normal, compile_and_run, [''])
test('NumConstantFolding32', normal, compile_and_run, [''])
test('NumConstantFolding', normal, compile_and_run, [''])
+test('T19413', normal, compile_and_run, [''])