diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2015-01-28 14:31:52 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2015-01-28 14:32:31 +0000 |
commit | 276da7929c187f007c198a38e88bdad91866e500 (patch) | |
tree | 11fdde58d4566f05f525a487e31c44301f93f04d /compiler/typecheck/TcErrors.hs | |
parent | cf3e3406a0b66f1831decd88f8deda5e297f4395 (diff) | |
download | haskell-276da7929c187f007c198a38e88bdad91866e500.tar.gz |
Improve error message on typed holes, and user manual (Tradc #10040)
Diffstat (limited to 'compiler/typecheck/TcErrors.hs')
-rw-r--r-- | compiler/typecheck/TcErrors.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/typecheck/TcErrors.hs b/compiler/typecheck/TcErrors.hs index 31772a229c..6b9be0112f 100644 --- a/compiler/typecheck/TcErrors.hs +++ b/compiler/typecheck/TcErrors.hs @@ -636,16 +636,22 @@ mkHoleError ctxt ct@(CHoleCan { cc_occ = occ, cc_hole = hole_sort }) tyvars_msg = map loc_msg tyvars msg = vcat [ hang (ptext (sLit "Found hole") <+> quotes (ppr occ)) 2 (ptext (sLit "with type:") <+> pprType (ctEvPred (ctEvidence ct))) - , ppUnless (null tyvars_msg) (ptext (sLit "Where:") <+> vcat tyvars_msg) - , pts_hint ] + , ppUnless (null tyvars) (ptext (sLit "Where:") <+> vcat tyvars_msg) + , hint ] ; (ctxt, binds_doc, _) <- relevantBindings False ctxt ct -- The 'False' means "don't filter the bindings"; see Trac #8191 ; mkErrorMsgFromCt ctxt ct (msg $$ binds_doc) } where - pts_hint + hint | TypeHole <- hole_sort , HoleError <- cec_type_holes ctxt = ptext (sLit "To use the inferred type, enable PartialTypeSignatures") + + | ExprHole <- hole_sort -- Give hint for, say, f x = _x + , lengthFS (occNameFS occ) > 1 -- Don't give this hint for plain "_", which isn't legal Haskell + = ptext (sLit "Or perhaps") <+> quotes (ppr occ) + <+> ptext (sLit "is mis-spelled, or not in scope") + | otherwise = empty |