X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Frename%2FRnBinds.lhs;h=029f51c84280b056a1928b057190c1c8359249c7;hp=d7a5952ee297a5896cd45b7e6edda3a3253a03ad;hb=2eb04ca0f8d0ec72b417cddc60672c696b4a3daa;hpb=bb7d80b3b8d1396d481d3b24302bee24a3d92f71 diff --git a/compiler/rename/RnBinds.lhs b/compiler/rename/RnBinds.lhs index d7a5952..029f51c 100644 --- a/compiler/rename/RnBinds.lhs +++ b/compiler/rename/RnBinds.lhs @@ -27,18 +27,18 @@ import TcRnMonad import RnTypes ( rnHsSigType, rnLHsType, rnHsTypeFVs, rnLPat, rnPatsAndThen, patSigErr, checkPrecMatch ) import RnEnv ( bindLocatedLocalsRn, lookupLocatedBndrRn, - lookupLocatedInstDeclBndr, newIPNameRn, + lookupInstDeclBndr, newIPNameRn, lookupLocatedSigOccRn, bindPatSigTyVarsFV, bindLocalFixities, bindSigTyVarsFV, warnUnusedLocalBinds, mapFvRn, extendTyVarEnvFVRn, ) import DynFlags ( DynFlag(..) ) -import Name ( Name, nameOccName, nameSrcLoc ) +import Name import NameEnv import NameSet import PrelNames ( isUnboundName ) import RdrName ( RdrName, rdrNameOcc ) -import SrcLoc ( mkSrcSpan, Located(..), unLoc ) +import SrcLoc ( Located(..), unLoc ) import ListSetOps ( findDupsEq ) import BasicTypes ( RecFlag(..) ) import Digraph ( SCC(..), stronglyConnComp ) @@ -422,7 +422,7 @@ rnMethodBinds cls sig_fn gen_tyvars binds rnMethodBind cls sig_fn gen_tyvars (L loc (FunBind { fun_id = name, fun_infix = inf, fun_matches = MatchGroup matches _ })) = setSrcSpan loc $ - lookupLocatedInstDeclBndr cls name `thenM` \ sel_name -> + lookupInstDeclBndr cls name `thenM` \ sel_name -> let plain_name = unLoc sel_name in -- We use the selector name as the binder @@ -629,10 +629,20 @@ dupSigDeclErr sigs@(L loc sig : _) ppr_sig (L loc sig) = ppr loc <> colon <+> ppr sig unknownSigErr (L loc sig) - = addErrAt loc $ - sep [ptext SLIT("Misplaced") <+> what_it_is <> colon, ppr sig] + = do { mod <- getModule + ; addErrAt loc $ + vcat [sep [ptext SLIT("Misplaced") <+> what_it_is <> colon, ppr sig], + extra_stuff mod sig] } where what_it_is = hsSigDoc sig + extra_stuff mod (TypeSig (L _ n) _) + | nameIsLocalOrFrom mod n + = ptext SLIT("The type signature must be given where") + <+> quotes (ppr n) <+> ptext SLIT("is declared") + | otherwise + = ptext SLIT("You cannot give a type signature for an imported value") + + extra_stuff mod other = empty methodBindErr mbind = hang (ptext SLIT("Pattern bindings (except simple variables) not allowed in instance declarations"))