From: simonpj Date: Wed, 29 May 2002 13:09:24 +0000 (+0000) Subject: [project @ 2002-05-29 13:09:24 by simonpj] X-Git-Tag: Approx_11550_changesets_converted~2006 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=52671283f2c6b313a9d81e7ceb6b849415e6a76a;p=ghc-hetmet.git [project @ 2002-05-29 13:09:24 by simonpj] Wibble to previous commit on negative literals in patterns (fixes crash in GHC/Real.lhs) --- diff --git a/ghc/compiler/typecheck/TcPat.lhs b/ghc/compiler/typecheck/TcPat.lhs index e4decd0..548f710 100644 --- a/ghc/compiler/typecheck/TcPat.lhs +++ b/ghc/compiler/typecheck/TcPat.lhs @@ -323,9 +323,15 @@ tcPat tc_bndr pat@(NPatIn over_lit mb_neg) pat_ty emptyBag, emptyBag, emptyLIE) where origin = PatOrigin pat - lit' = case over_lit of - HsIntegral i _ -> HsInteger i - HsFractional f _ -> HsRat f pat_ty + + -- The literal in an NPatIn is always positive... + -- But in NPat, the literal is used to find identical patterns + -- so we must negate the literal when necessary! + lit' = case (over_lit, mb_neg) of + (HsIntegral i _, Nothing) -> HsInteger i + (HsIntegral i _, Just _) -> HsInteger (-i) + (HsFractional f _, Nothing) -> HsRat f pat_ty + (HsFractional f _, Just _) -> HsRat (-f) pat_ty \end{code} %************************************************************************