on iko/ghcjs-patch-master help sign in
Patch for https://gitlab.haskell.org/ghc/ghc/-/issues/18708 by author @sgraf812 (#1321)

Backported to potential GHC 8.10.8 here: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6554

commit9009a48f29010b8972c79f5e9e570ee70563bb12 authorPeter Becich <peterbecich@gmail.com> dateSun 26 Dec 2021, 23:23 (5 years ago) parent2e30cba
2 files changed+40
overlays/bootstrap.nix+1 overlays/patches/ghc/issue-18708.patch+39
overlays/bootstrap.nix+1
@@ -186,6 +186,7 @@ in {
186186 ++ fromUntil "8.10" "9.2.2" ./patches/ghc/MR6654-nonmoving-maxmem.patch # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6654
187187 ++ fromUntil "8.10" "8.10.8" ./patches/ghc/MR6617-nonmoving-mvar.patch # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6617
188188 ++ fromUntil "8.10" "8.10.8" ./patches/ghc/MR6595-nonmoving-mutvar.patch # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6595
189+ ++ fromUntil "8.10" "8.10.8" ./patches/ghc/issue-18708.patch # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6554
189190 ;
190191 in ({
191192 ghc844 = final.callPackage ../compiler/ghc {
overlays/patches/ghc/issue-18708.patchnew file+39
@@ -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)
13+ (Var x, args)
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
21++ (Var x, args)
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
29+ | otherwise
30+ = False
31+
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
36++
37+ instance Outputable PmLitValue where
38+ ppr (PmLitInt i) = ppr i
39+ ppr (PmLitRat r) = ppr (double (fromRat r)) -- good enough