X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Frename%2FRnBinds.lhs;h=ff0629ac688b1742d4e74edf84523660b317611c;hp=a96c63f63982bff7156c05170baad9ee45a8fcd7;hb=7d52c74cab50d3c9a5e76be5b97d63b60069bc2e;hpb=b88025eabcd83f65d1d81f09272f5172f06a60e7 diff --git a/compiler/rename/RnBinds.lhs b/compiler/rename/RnBinds.lhs index a96c63f..ff0629a 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 ) @@ -178,20 +178,7 @@ rnTopBindsBoot (ValBindsIn mbinds sigs) ; return (ValBindsOut [] sigs', usesOnly (hsSigsFVs sigs')) } rnTopBindsSrc :: HsValBinds RdrName -> RnM (HsValBinds Name, DefUses) -rnTopBindsSrc binds@(ValBindsIn mbinds _) - = do { (binds', dus) <- rnValBinds noTrim binds - - -- Warn about missing signatures, - ; let { ValBindsOut _ sigs' = binds' - ; ty_sig_vars = mkNameSet [ unLoc n | L _ (TypeSig n _) <- sigs'] - ; un_sigd_bndrs = duDefs dus `minusNameSet` ty_sig_vars } - - ; warn_missing_sigs <- doptM Opt_WarnMissingSigs - ; ifM (warn_missing_sigs) - (mappM_ missingSigWarn (nameSetToList un_sigd_bndrs)) - - ; return (binds', dus) - } +rnTopBindsSrc binds = rnValBinds noTrim binds \end{code} @@ -435,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 @@ -609,11 +596,11 @@ rnGRHS :: HsMatchContext Name -> LGRHS RdrName -> RnM (LGRHS Name, FreeVars) rnGRHS ctxt = wrapLocFstM (rnGRHS' ctxt) rnGRHS' ctxt (GRHS guards rhs) - = do { opt_GlasgowExts <- doptM Opt_GlasgowExts + = do { pattern_guards_allowed <- doptM Opt_PatternGuards ; ((guards', rhs'), fvs) <- rnStmts (PatGuard ctxt) guards $ rnLExpr rhs - ; checkM (opt_GlasgowExts || is_standard_guard guards') + ; checkM (pattern_guards_allowed || is_standard_guard guards') (addWarn (nonStdGuardErr guards')) ; return (GRHS guards' rhs', fvs) } @@ -642,16 +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") -missingSigWarn var - = addWarnAt (mkSrcSpan loc loc) $ - sep [ptext SLIT("Definition but no type signature for"), quotes (ppr var)] - where - loc = nameSrcLoc var -- TODO: make a proper span + extra_stuff mod other = empty methodBindErr mbind = hang (ptext SLIT("Pattern bindings (except simple variables) not allowed in instance declarations")) @@ -662,6 +653,6 @@ bindsInHsBootFile mbinds 2 (ppr mbinds) nonStdGuardErr guards - = hang (ptext SLIT("accepting non-standard pattern guards (-fglasgow-exts to suppress this message)")) + = hang (ptext SLIT("accepting non-standard pattern guards (use -XPatternGuards to suppress this message)")) 4 (interpp'SP guards) \end{code}