diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-04-12 12:38:45 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-04-14 19:42:53 -0400 |
commit | cc1ba576d26b90c0c01aa43e7100c94ee3a287ad (patch) | |
tree | 3271e7d0fc6d614def8a06347c884d9bbec0caac /compiler/GHC/HsToCore | |
parent | 5f1722994dc29a86f5495ebafb15475a46b0532c (diff) | |
download | haskell-cc1ba576d26b90c0c01aa43e7100c94ee3a287ad.tar.gz |
Fix some negation issues when creating FractionalLit
There were two different issues:
1. integralFractionalLit needed to be passed an already negated value. (T19680)
2. negateFractionalLit did not actually negate the argument, only
flipped the negation flag. (T19680A)
Fixes #19680
Diffstat (limited to 'compiler/GHC/HsToCore')
-rw-r--r-- | compiler/GHC/HsToCore/Match.hs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/GHC/HsToCore/Match.hs b/compiler/GHC/HsToCore/Match.hs index d3b2776d93..6bd3860e42 100644 --- a/compiler/GHC/HsToCore/Match.hs +++ b/compiler/GHC/HsToCore/Match.hs @@ -1165,7 +1165,9 @@ patGroup _ (WildPat {}) = PgAny patGroup _ (BangPat {}) = PgBang patGroup _ (NPat _ (L _ (OverLit {ol_val=oval})) mb_neg _) = case (oval, isJust mb_neg) of - (HsIntegral i, is_neg) -> PgN (integralFractionalLit is_neg (il_value i)) + (HsIntegral i, is_neg) -> PgN (integralFractionalLit is_neg (if is_neg + then negate (il_value i) + else il_value i)) (HsFractional f, is_neg) | is_neg -> PgN $! negateFractionalLit f | otherwise -> PgN f |