diff options
author | Alec Theriault <alec.theriault@gmail.com> | 2018-09-25 11:58:12 +0200 |
---|---|---|
committer | Krzysztof Gogolewski <krz.gogolewski@gmail.com> | 2018-09-25 11:58:12 +0200 |
commit | 9bfbc4e16d511678cffa9f7f76b369c8cfca7a66 (patch) | |
tree | 16c1f3ba6ef57d056a863cb71e67aaa349c1a73a /compiler/parser | |
parent | a38eaa66af711abd22a72774ae0f4cf95b2bff7a (diff) | |
download | haskell-9bfbc4e16d511678cffa9f7f76b369c8cfca7a66.tar.gz |
Don't show constraint tuples in errors (#14907)
Summary:
This means that 'GHC.Classes.(%,%)' is no longer mentioned in
error messages for things like
class (a,b,c) -- outside of 'GHC.Classes'
class (a,Bool)
Test Plan: make TEST=T14907a && make TEST=T14907b
Reviewers: RyanGlScott, bgamari
Reviewed By: RyanGlScott
Subscribers: rwbarton, carter
GHC Trac Issues: #14907
Differential Revision: https://phabricator.haskell.org/D5172
Diffstat (limited to 'compiler/parser')
-rw-r--r-- | compiler/parser/RdrHsSyn.hs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/compiler/parser/RdrHsSyn.hs b/compiler/parser/RdrHsSyn.hs index 5784b9ecdb..e4f74d6b73 100644 --- a/compiler/parser/RdrHsSyn.hs +++ b/compiler/parser/RdrHsSyn.hs @@ -25,6 +25,7 @@ module RdrHsSyn ( mkTyClD, mkInstD, mkRdrRecordCon, mkRdrRecordUpd, setRdrNameSpace, + filterCTuple, cvBindGroup, cvBindsAndSigs, @@ -91,7 +92,8 @@ import Lexeme ( isLexCon ) import Type ( TyThing(..) ) import TysWiredIn ( cTupleTyConName, tupleTyCon, tupleDataCon, nilDataConName, nilDataConKey, - listTyConName, listTyConKey, eqTyCon_RDR ) + listTyConName, listTyConKey, eqTyCon_RDR, + tupleTyConName, cTupleTyConNameArity_maybe ) import ForeignCall import PrelNames ( forall_tv_RDR, allNameStrings ) import SrcLoc @@ -765,6 +767,13 @@ data_con_ty_con dc | otherwise -- See Note [setRdrNameSpace for wired-in names] = Unqual (setOccNameSpace tcClsName (getOccName dc)) +-- | Replaces constraint tuple names with corresponding boxed ones. +filterCTuple :: RdrName -> RdrName +filterCTuple (Exact n) + | Just arity <- cTupleTyConNameArity_maybe n + = Exact $ tupleTyConName BoxedTuple arity +filterCTuple rdr = rdr + {- Note [setRdrNameSpace for wired-in names] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -809,12 +818,19 @@ checkTyVars pp_what equals_or_where tc tparms chk t@(L loc _) = Left (loc, vcat [ text "Unexpected type" <+> quotes (ppr t) - , text "In the" <+> pp_what <+> ptext (sLit "declaration for") <+> quotes (ppr tc) + , text "In the" <+> pp_what <+> ptext (sLit "declaration for") <+> quotes tc' , vcat[ (text "A" <+> pp_what <+> ptext (sLit "declaration should have form")) - , nest 2 (pp_what <+> ppr tc + , nest 2 (pp_what <+> tc' <+> hsep (map text (takeList tparms allNameStrings)) <+> equals_or_where) ] ]) + -- Avoid printing a constraint tuple in the error message. Print + -- a plain old tuple instead (since that's what the user probably + -- wrote). See #14907 + tc' = ppr $ fmap filterCTuple tc + + + whereDots, equalsDots :: SDoc -- Second argument to checkTyVars whereDots = text "where ..." |