summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc/Instance
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-08-12 17:44:15 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-09-11 08:54:29 -0400
commit089de88ef5215de0f2db4c4babc556ac43f8232e (patch)
treec036813b9625dbb45b4577b09ec6ad31c45c1bce /compiler/GHC/Tc/Instance
parent74a87aa3046f3eb871e5442579e9a2945ef691d4 (diff)
downloadhaskell-089de88ef5215de0f2db4c4babc556ac43f8232e.tar.gz
Canonicalize bignum literals
Before this patch Integer and Natural literals were desugared into "real" Core in Core prep. Now we desugar them directly into their final ConApp form in HsToCore. We only keep the double representation for BigNat# (literals larger than a machine Word/Int) which are still desugared in Core prep. Using the final form directly allows case-of-known-constructor to fire for bignum literals, fixing #20245. Slight increase (+2.3) in T4801 which is a pathological case with Integer literals. Metric Increase: T4801 T11545
Diffstat (limited to 'compiler/GHC/Tc/Instance')
-rw-r--r--compiler/GHC/Tc/Instance/Class.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/GHC/Tc/Instance/Class.hs b/compiler/GHC/Tc/Instance/Class.hs
index f80d3eaf93..757226ed28 100644
--- a/compiler/GHC/Tc/Instance/Class.hs
+++ b/compiler/GHC/Tc/Instance/Class.hs
@@ -359,8 +359,8 @@ matchKnownNat :: DynFlags
-> Bool -- True <=> caller is the short-cut solver
-- See Note [Shortcut solving: overlap]
-> Class -> [Type] -> TcM ClsInstResult
-matchKnownNat _ _ clas [ty] -- clas = KnownNat
- | Just n <- isNumLitTy ty = makeLitDict clas ty (mkNaturalExpr n)
+matchKnownNat dflags _ clas [ty] -- clas = KnownNat
+ | Just n <- isNumLitTy ty = makeLitDict clas ty (mkNaturalExpr (targetPlatform dflags) n)
matchKnownNat df sc clas tys = matchInstEnv df sc clas tys
-- See Note [Fabricating Evidence for Literals in Backpack] for why
-- this lookup into the instance environment is required.