From 98a1ebecb6d22d793b1d9f8e1d24ecbb5a2d130f Mon Sep 17 00:00:00 2001 From: simonm Date: Mon, 2 Feb 1998 16:47:53 +0000 Subject: [PATCH] [project @ 1998-02-02 16:47:53 by simonm] Short-cut unary '-' applied to an integer constant, before literal overloading kicks in. --- ghc/compiler/typecheck/TcExpr.lhs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ghc/compiler/typecheck/TcExpr.lhs b/ghc/compiler/typecheck/TcExpr.lhs index 34bb8cc..38a124e 100644 --- a/ghc/compiler/typecheck/TcExpr.lhs +++ b/ghc/compiler/typecheck/TcExpr.lhs @@ -185,7 +185,15 @@ tcExpr (HsLit lit@(HsString str)) res_ty tcExpr (HsPar expr) res_ty -- preserve parens so printing needn't guess where they go = tcExpr expr res_ty -tcExpr (NegApp expr neg) res_ty = tcExpr (HsApp neg expr) res_ty +-- perform the negate *before* overloading the integer, since the case +-- of minBound on Ints fails otherwise. Could be done elsewhere, but +-- convenient to do it here. + +tcExpr (NegApp (HsLit (HsInt i)) neg) res_ty + = tcExpr (HsLit (HsInt (-i))) res_ty + +tcExpr (NegApp expr neg) res_ty + = tcExpr (HsApp neg expr) res_ty tcExpr (HsLam match) res_ty = tcMatchExpected [] res_ty match `thenTc` \ (match',lie) -> -- 1.7.10.4