[project @ 1997-10-16 12:17:05 by simonm]
authorsimonm <unknown>
Thu, 16 Oct 1997 12:17:07 +0000 (12:17 +0000)
committersimonm <unknown>
Thu, 16 Oct 1997 12:17:07 +0000 (12:17 +0000)
polymorphic recursion/space leak test

ghc/tests/typecheck/should_run/tcrun002.hs [new file with mode: 0644]
ghc/tests/typecheck/should_run/tcrun002.stdout [new file with mode: 0644]

diff --git a/ghc/tests/typecheck/should_run/tcrun002.hs b/ghc/tests/typecheck/should_run/tcrun002.hs
new file mode 100644 (file)
index 0000000..7917402
--- /dev/null
@@ -0,0 +1,18 @@
+module Main where
+
+--!!! space leak from overloading !!!
+
+-- This program develops a space leak if sfoldl isn't compiled with some
+-- care.  See comment about polymorphic recursion in TcMonoBinds.lhs
+
+import System(getArgs)
+import IOBase
+import STBase
+
+sfoldl :: Eval a => (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 })
diff --git a/ghc/tests/typecheck/should_run/tcrun002.stdout b/ghc/tests/typecheck/should_run/tcrun002.stdout
new file mode 100644 (file)
index 0000000..928909f
--- /dev/null
@@ -0,0 +1 @@
+-1474736480