diff --git a/ghc/compiler/typecheck/TcExpr.lhs b/ghc/compiler/typecheck/TcExpr.lhs index 34bb8cce2823de89b62e05b84e43063d23df93eb..38a124ec5afe3e794e122760f896b6b97d760cb5 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) ->