summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-03-11 11:13:31 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2014-03-11 11:15:55 +0000
commitef44a429af4a630a153b5774d0e19dbcad8328d5 (patch)
treec32a11d7a36d9308f4fc2f8aba583dbb29799927 /testsuite/tests/simplCore
parenta10ed3e64336e272137e1743c36970b36f7076c7 (diff)
downloadhaskell-ef44a429af4a630a153b5774d0e19dbcad8328d5.tar.gz
Make SetLevels do substitution properly (fixes Trac #8714)
Nowadays SetLevels floats case expressions as well as let-bindings, and case expressions bind type variables. We need to clone all such floated binders, to avoid accidental name capture. But I'd forgotten to substitute for the cloned type variables, causing #8714. (In the olden days only Ids were cloned, from let-bindings.) This patch fixes the bug and does quite a bit of clean-up refactoring as well, by putting the context level in the LvlEnv. There is no effect on performance, except that nofib 'rewrite' improves allocations by 3%. On investigation I think it was a fluke to do with loop-cutting in big letrec nests. But at least it's a fluke in the right direction. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- Min -0.4% -3.0% -19.4% -19.4% -26.7% Max -0.0% +0.0% +17.9% +17.9% 0.0% Geometric Mean -0.1% -0.0% -0.7% -0.7% -0.4%
Diffstat (limited to 'testsuite/tests/simplCore')
-rw-r--r--testsuite/tests/simplCore/should_compile/T8714.hs9
-rw-r--r--testsuite/tests/simplCore/should_compile/all.T1
2 files changed, 10 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_compile/T8714.hs b/testsuite/tests/simplCore/should_compile/T8714.hs
new file mode 100644
index 0000000000..8199d6fd59
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T8714.hs
@@ -0,0 +1,9 @@
+{-# LANGUAGE ExistentialQuantification #-}
+module T8714 where
+
+data HLState = forall a. HLState (a -> a) !a
+
+data BufferImpl = FBufferData !HLState
+
+focusAst :: BufferImpl -> HLState
+focusAst (FBufferData (HLState f x)) = HLState f (f x)
diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T
index ecc88e176e..2f2b3379b9 100644
--- a/testsuite/tests/simplCore/should_compile/all.T
+++ b/testsuite/tests/simplCore/should_compile/all.T
@@ -198,3 +198,4 @@ test('T5996',
run_command,
['$MAKE -s --no-print-directory T5996'])
test('T8537', normal, compile, [''])
+test('T8714', normal, compile, [''])