@@ -0,0 +1,39 @@
1+diff --git a/compiler/GHC/HsToCore/PmCheck/Types.hs b/compiler/GHC/HsToCore/PmCheck/Types.hs
2+index 10f172a430..06678b4060 100644
3+--- a/compiler/GHC/HsToCore/PmCheck/Types.hs
4++++ b/compiler/GHC/HsToCore/PmCheck/Types.hs
5+@@ -299,16 +299,17 @@ coreExprAsPmLit e = case collectArgs e of
6+ -- Take care of -XRebindableSyntax. The last argument should be the (only)
7+ -- integer literal, otherwise we can't really do much about it.
8+ | [Lit l] <- dropWhile (not . is_lit) args
9+- -- getOccFS because of -XRebindableSyntax
10+- , getOccFS (idName x) == getOccFS fromIntegerName
11++ , is_rebound_name x fromIntegerName
12+ -> literalToPmLit (literalType l) l >>= overloadPmLit (exprType e)
14+ -- Similar to fromInteger case
15+ | [r] <- dropWhile (not . is_ratio) args
16+- , getOccFS (idName x) == getOccFS fromRationalName
17++ , is_rebound_name x fromRationalName
18+ -> coreExprAsPmLit r >>= overloadPmLit (exprType e)
19+- (Var x, [Type _ty, _dict, s])
20+- | idName x == fromStringName
22++ | is_rebound_name x fromStringName
23++ -- With -XRebindableSyntax or without: The first String argument is what we are after
24++ , s:_ <- filter (eqType stringTy . exprType) args
25+ -- NB: Calls coreExprAsPmLit and then overloadPmLit, so that we return PmLitOverStrings
26+ -> coreExprAsPmLit s >>= overloadPmLit (exprType e)
27+ -- These last two cases handle String literals
28+@@ -331,6 +332,11 @@ coreExprAsPmLit e = case collectArgs e of
32++ -- | Compares the given Id to the Name based on OccName, to detect
33++ -- -XRebindableSyntax.
34++ is_rebound_name :: Id -> Name -> Bool
35++ is_rebound_name x n = getOccFS (idName x) == getOccFS n
37+ instance Outputable PmLitValue where
38+ ppr (PmLitInt i) = ppr i
39+ ppr (PmLitRat r) = ppr (double (fromRat r)) -- good enough