[commit: ghc] master: Suppress a misleading error message (Trac #7869) (b988dc3)

Simon Peyton Jones simonpj at microsoft.com
Tue Apr 30 10:52:03 CEST 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

https://github.com/ghc/ghc/commit/b988dc39a06278acc2373ba9a40ee08da0127411

>---------------------------------------------------------------

commit b988dc39a06278acc2373ba9a40ee08da0127411
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Mon Apr 29 17:28:20 2013 +0100

    Suppress a misleading error message (Trac #7869)
    
    We were saying
         The function `f' is applied to one argument,
         but its type `[a] -> b' has only one
    which is obviously bogus.
    
    This fix suppresses the explanation in cases where it may not
    be the *right* explanation.

>---------------------------------------------------------------

 compiler/typecheck/TcUnify.lhs | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/compiler/typecheck/TcUnify.lhs b/compiler/typecheck/TcUnify.lhs
index 601135d..4749d0c 100644
--- a/compiler/typecheck/TcUnify.lhs
+++ b/compiler/typecheck/TcUnify.lhs
@@ -153,12 +153,15 @@ matchExpectedFunTys herald arity orig_ty
 	       Flexi        -> defer n_req ty }
 
        -- In all other cases we bale out into ordinary unification
-    go n_req ty = defer n_req ty
+       -- However unlike the meta-tyvar case, we are sure that the
+       -- number of arrows doesn't match up, so we can add a bit 
+       -- more context to the error message (cf Trac #7869)
+    go n_req ty = addErrCtxtM mk_ctxt $
+                  defer n_req ty
 
     ------------
     defer n_req fun_ty 
-      = addErrCtxtM mk_ctxt $
-        do { arg_tys <- newFlexiTyVarTys n_req openTypeKind
+      = do { arg_tys <- newFlexiTyVarTys n_req openTypeKind
                         -- See Note [Foralls to left of arrow]
            ; res_ty  <- newFlexiTyVarTy openTypeKind
            ; co   <- unifyType fun_ty (mkFunTys arg_tys res_ty)





More information about the ghc-commits mailing list