summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2016-01-19 16:30:26 +0100
committerBen Gamari <ben@smart-cactus.org>2016-01-20 17:08:05 +0100
commit5cce09543db827e662539523ffff4513deb92777 (patch)
tree56b57340d0853f6a59377119cadb5863f57866bd /compiler
parent0373a8458a9d5ed0732d06ffd082b939c11b6adc (diff)
downloadhaskell-5cce09543db827e662539523ffff4513deb92777.tar.gz
Use (&&) instead of `if` in Ix derivation
We were previously using `if` in the derivation of `Ix` instances. This interacts badly with RebindableSyntax as the typechecker doesn't infer the type of the argument we give to `tagToEnum#`. Previously we produced, `if (ch >= ah) then (ch <= bh) else False`. We now produce `(ch >= ah) && (ch <= bh)` Fixes #11396. Test Plan: Validate Reviewers: austin, simonpj Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1797 GHC Trac Issues: #11396
Diffstat (limited to 'compiler')
-rw-r--r--compiler/typecheck/TcGenDeriv.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/typecheck/TcGenDeriv.hs b/compiler/typecheck/TcGenDeriv.hs
index c4279a7698..218c0a4991 100644
--- a/compiler/typecheck/TcGenDeriv.hs
+++ b/compiler/typecheck/TcGenDeriv.hs
@@ -783,16 +783,19 @@ gen_Ix_binds loc tycon
))
)
+ -- This produces something like `(ch >= ah) && (ch <= bh)`
enum_inRange
= mk_easy_FunBind loc inRange_RDR [nlTuplePat [a_Pat, b_Pat] Boxed, c_Pat] $
untag_Expr tycon [(a_RDR, ah_RDR)] (
untag_Expr tycon [(b_RDR, bh_RDR)] (
untag_Expr tycon [(c_RDR, ch_RDR)] (
- nlHsIf (genPrimOpApp (nlHsVar ch_RDR) geInt_RDR (nlHsVar ah_RDR)) (
- (genPrimOpApp (nlHsVar ch_RDR) leInt_RDR (nlHsVar bh_RDR))
- ) {-else-} (
- false_Expr
- ))))
+ -- This used to use `if`, which interacts badly with RebindableSyntax.
+ -- See #11396.
+ nlHsApps and_RDR
+ [ genPrimOpApp (nlHsVar ch_RDR) geInt_RDR (nlHsVar ah_RDR)
+ , genPrimOpApp (nlHsVar ch_RDR) leInt_RDR (nlHsVar bh_RDR)
+ ]
+ )))
--------------------------------------------------------------
single_con_ixes