X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Frename%2FRnPat.lhs;h=c06aa38e06ce862bbf5ebf45def618a8060ff3dc;hp=63672553501c4ccd7f83d57c5766b942076264b7;hb=85f969a6585c06168645114d9524e7169dbc6e32;hpb=dfa43eb4dd7cd898b4a0f55f51d1eace71f22762 diff --git a/compiler/rename/RnPat.lhs b/compiler/rename/RnPat.lhs index 6367255..c06aa38 100644 --- a/compiler/rename/RnPat.lhs +++ b/compiler/rename/RnPat.lhs @@ -133,9 +133,11 @@ which is how you go from a RdrName to a Name data NameMaker = LamMk -- Lambdas Bool -- True <=> report unused bindings + -- (even if True, the warning only comes out + -- if -fwarn-unused-matches is on) | LetMk -- Let bindings, incl top level - -- Do not check for unused bindings + -- Do *not* check for unused bindings (Maybe Module) -- Just m => top level of module m -- Nothing => not top level MiniFixityEnv @@ -146,8 +148,14 @@ topRecNameMaker mod fix_env = LetMk (Just mod) fix_env localRecNameMaker :: MiniFixityEnv -> NameMaker localRecNameMaker fix_env = LetMk Nothing fix_env -matchNameMaker :: NameMaker -matchNameMaker = LamMk True +matchNameMaker :: HsMatchContext a -> NameMaker +matchNameMaker ctxt = LamMk report_unused + where + -- Do not report unused names in interactive contexts + -- i.e. when you type 'x <- e' at the GHCi prompt + report_unused = case ctxt of + StmtCtxt GhciStmt -> False + _ -> True newName :: NameMaker -> Located RdrName -> CpsRn Name newName (LamMk report_unused) rdr_name @@ -212,8 +220,8 @@ rnPats ctxt pats thing_inside -- (0) bring into scope all of the type variables bound by the patterns -- (1) rename the patterns, bringing into scope all of the term variables -- (2) then do the thing inside. - ; bindPatSigTyVarsFV (collectSigTysFromPats pats) $ - unCpsRn (rnLPatsAndThen matchNameMaker pats) $ \ pats' -> do + ; bindPatSigTyVarsFV (collectSigTysFromPats pats) $ + unCpsRn (rnLPatsAndThen (matchNameMaker ctxt) pats) $ \ pats' -> do { -- Check for duplicated and shadowed names -- Because we don't bind the vars all at once, we can't -- check incrementally for duplicates;