Fix deriving Ord when RebindableSyntax is enabled
authorAndrew Farmer <anfarmer@fb.com>
Sat, 21 May 2016 16:38:47 +0000 (18:38 +0200)
committerBen Gamari <ben@smart-cactus.org>
Mon, 25 Jul 2016 15:06:09 +0000 (17:06 +0200)
commita064fa362d7e9ab33403b56c8f3e1aac0df07aca
tree1182b6ede2f9ef3293204bf5bb7250fcc5072f25
parentba414165bbf06e3b3c4f6e65301749d197beb69a
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

(cherry picked from commit 527ed7246a35fe8bab89c7c582084cd20661018a)
compiler/hsSyn/HsUtils.hs
compiler/typecheck/TcGenDeriv.hs
testsuite/tests/rebindable/T12080.hs [new file with mode: 0644]
testsuite/tests/rebindable/all.T