summaryrefslogtreecommitdiff
path: root/testsuite/tests/deSugar/should_compile
diff options
context:
space:
mode:
authorAlexis King <lexi.lambda@gmail.com>2020-04-30 22:50:29 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-05-03 04:42:12 -0400
commitb465dd4500beffe919e8b8dcd075008399fbf446 (patch)
tree72192f4d67e01d5d2e21414f403e1abdb8ab41fa /testsuite/tests/deSugar/should_compile
parent02543d5ef9bd7a910fc9fece895780583ab9635a (diff)
downloadhaskell-b465dd4500beffe919e8b8dcd075008399fbf446.tar.gz
Flatten nested casts in the simple optimizer
Normally, we aren’t supposed to generated any nested casts, since mkCast takes care to flatten them, but the simple optimizer didn’t use mkCast, so they could show up after inlining. This isn’t really a problem, since the simplifier will clean them up immediately anyway, but it can clutter the -ddump-ds output, and it’s an extremely easy fix. closes #18112
Diffstat (limited to 'testsuite/tests/deSugar/should_compile')
-rw-r--r--testsuite/tests/deSugar/should_compile/T18112.hs14
-rw-r--r--testsuite/tests/deSugar/should_compile/all.T1
2 files changed, 15 insertions, 0 deletions
diff --git a/testsuite/tests/deSugar/should_compile/T18112.hs b/testsuite/tests/deSugar/should_compile/T18112.hs
new file mode 100644
index 0000000000..972bb7c0b0
--- /dev/null
+++ b/testsuite/tests/deSugar/should_compile/T18112.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE TypeFamilies #-}
+module T18112 where
+
+type family F a where
+ F Int = String
+
+-- This test is really testing the simple optimizer. We expect the
+-- optimized desugared output to contain no casts, since the simple
+-- optimizer should fuse the two casts together after inlining y.
+
+blah :: Bool -> String
+blah x = let y :: F Int
+ y = show x
+ in y
diff --git a/testsuite/tests/deSugar/should_compile/all.T b/testsuite/tests/deSugar/should_compile/all.T
index f72a854045..888369b849 100644
--- a/testsuite/tests/deSugar/should_compile/all.T
+++ b/testsuite/tests/deSugar/should_compile/all.T
@@ -109,3 +109,4 @@ test('T14773b', normal, compile, ['-Wincomplete-patterns'])
test('T14815', [], makefile_test, ['T14815'])
test('T13208', [], makefile_test, ['T13208'])
test('T16615', normal, compile, ['-ddump-ds -dsuppress-uniques'])
+test('T18112', [grep_errmsg('cast')], compile, ['-ddump-ds'])