summaryrefslogtreecommitdiff
path: root/testsuite/tests/rebindable
diff options
context:
space:
mode:
authorAndrew Farmer <anfarmer@fb.com>2016-05-21 18:38:47 +0200
committerBen Gamari <ben@smart-cactus.org>2016-05-21 19:10:59 +0200
commit527ed7246a35fe8bab89c7c582084cd20661018a (patch)
tree0d5dc825e6ab610f8dec5dd4c42f27a9605c3bf4 /testsuite/tests/rebindable
parentda3c1ebb8a57e81f12c5be192e477f79158a2398 (diff)
downloadhaskell-527ed7246a35fe8bab89c7c582084cd20661018a.tar.gz
Fix deriving Ord when RebindableSyntax is enabled
Deriving clauses (Ord especially) generated if-expressions with nlHsIf which were subject to RebindableSyntax. This changes nlHsIf to generate concrete if-expressions. There was also an error about calling tagToEnum# at a polymorphic type, which is not allowed. Fixing nlHsIf didn't fix this for some reason, so I generated a type ascription around the call to tagToEnum#. Not sure why the typechecker could not figure this out. Test Plan: Added a test, ran validate. Reviewers: simonpj, simonmar, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2247 GHC Trac Issues: #12080
Diffstat (limited to 'testsuite/tests/rebindable')
-rw-r--r--testsuite/tests/rebindable/T12080.hs16
-rw-r--r--testsuite/tests/rebindable/all.T1
2 files changed, 17 insertions, 0 deletions
diff --git a/testsuite/tests/rebindable/T12080.hs b/testsuite/tests/rebindable/T12080.hs
new file mode 100644
index 0000000000..5413ed060c
--- /dev/null
+++ b/testsuite/tests/rebindable/T12080.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE RebindableSyntax #-}
+
+import Prelude
+
+class IfThenElse a b where
+ ifThenElse :: a -> b -> b -> b
+
+instance IfThenElse Bool b where
+ ifThenElse c x y = if c then x else y
+
+data Foo = Foo | Bar | Baz deriving (Eq, Ord)
+
+main :: IO ()
+main = print $ Foo < Bar
diff --git a/testsuite/tests/rebindable/all.T b/testsuite/tests/rebindable/all.T
index b42f884055..f1737e9603 100644
--- a/testsuite/tests/rebindable/all.T
+++ b/testsuite/tests/rebindable/all.T
@@ -32,3 +32,4 @@ test('T4851', normal, compile, [''])
test('T5908', normal, compile, [''])
test('T10112', normal, compile, [''])
test('T11216', [expect_broken(11216)], compile, [''])
+test('T12080', normal, compile, [''])