summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_run/tcrun002.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/typecheck/should_run/tcrun002.hs')
-rw-r--r--testsuite/tests/typecheck/should_run/tcrun002.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_run/tcrun002.hs b/testsuite/tests/typecheck/should_run/tcrun002.hs
new file mode 100644
index 0000000000..45fe19fdc9
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/tcrun002.hs
@@ -0,0 +1,16 @@
+-- !!! space leak from overloading !!!
+module Main where
+
+-- This program develops a space leak if sfoldl isn't compiled with some
+-- care. See comment about polymorphic recursion in TcMonoBinds.lhs
+
+import System.Environment (getArgs)
+import GHC.IOBase
+
+sfoldl :: (a -> Int -> a) -> a -> [Int] -> a
+sfoldl f z [] = z
+sfoldl f z (x:xs) = _scc_ "sfoldl1" (sfoldl f fzx (fzx `seq` xs))
+ where fzx = _scc_ "fzx" (f z x)
+
+
+main = IO (\s -> case print (sfoldl (+) (0::Int) [1..200000]) of { IO a -> a s })