From: simonpj@microsoft.com Date: Wed, 22 Sep 2010 13:39:34 +0000 (+0000) Subject: Remove -fwarn-simple-patterns, and make -fwarn-incomplete-patterns include lambdas X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=a7554688338b04ec362bc475b0992ef8799c8bd0 Remove -fwarn-simple-patterns, and make -fwarn-incomplete-patterns include lambdas This makes \(x:xs) -> e want when you have -fwarn-incomplete-patterns, which is consistent. --- diff --git a/compiler/deSugar/Match.lhs b/compiler/deSugar/Match.lhs index 2c9aa0b..4bc0c4b 100644 --- a/compiler/deSugar/Match.lhs +++ b/compiler/deSugar/Match.lhs @@ -700,21 +700,14 @@ matchEquations :: HsMatchContext Name -> [Id] -> [EquationInfo] -> Type -> DsM CoreExpr matchEquations ctxt vars eqns_info rhs_ty - = do { dflags <- getDOptsDs - ; locn <- getSrcSpanDs - ; let ds_ctxt = DsMatchContext ctxt locn + = do { locn <- getSrcSpanDs + ; let ds_ctxt = DsMatchContext ctxt locn error_doc = matchContextErrString ctxt - ; match_result <- match_fun dflags ds_ctxt vars rhs_ty eqns_info + ; match_result <- matchCheck ds_ctxt vars rhs_ty eqns_info ; fail_expr <- mkErrorAppDs pAT_ERROR_ID rhs_ty error_doc ; extractMatchResult match_result fail_expr } - where - match_fun dflags ds_ctxt - = case ctxt of - LambdaExpr | dopt Opt_WarnSimplePatterns dflags -> matchCheck ds_ctxt - | otherwise -> match - _ -> matchCheck ds_ctxt \end{code} %************************************************************************ @@ -734,7 +727,7 @@ matchSimply :: CoreExpr -- Scrutinee -> CoreExpr -- Return this if it matches -> CoreExpr -- Return this if it doesn't -> DsM CoreExpr - +-- Do not warn about incomplete patterns; see matchSinglePat comments matchSimply scrut hs_ctx pat result_expr fail_expr = do let match_result = cantFailMatchResult result_expr @@ -746,16 +739,11 @@ matchSimply scrut hs_ctx pat result_expr fail_expr = do matchSinglePat :: CoreExpr -> HsMatchContext Name -> LPat Id -> Type -> MatchResult -> DsM MatchResult -matchSinglePat (Var var) hs_ctx (L _ pat) ty match_result = do - dflags <- getDOptsDs - locn <- getSrcSpanDs - let - match_fn dflags - | dopt Opt_WarnSimplePatterns dflags = matchCheck ds_ctx - | otherwise = match - where - ds_ctx = DsMatchContext hs_ctx locn - match_fn dflags [var] ty [EqnInfo { eqn_pats = [pat], eqn_rhs = match_result }] +-- Do not warn about incomplete patterns +-- Used for things like [ e | pat <- stuff ], where +-- incomplete patterns are just fine +matchSinglePat (Var var) _ (L _ pat) ty match_result + = match [var] ty [EqnInfo { eqn_pats = [pat], eqn_rhs = match_result }] matchSinglePat scrut hs_ctx pat ty match_result = do var <- selectSimpleMatchVarL pat diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 6af63fe..467ebcb 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -192,7 +192,6 @@ data DynFlag | Opt_WarnMissingLocalSigs | Opt_WarnNameShadowing | Opt_WarnOverlappingPatterns - | Opt_WarnSimplePatterns | Opt_WarnTypeDefaults | Opt_WarnMonomorphism | Opt_WarnUnusedBinds @@ -1432,7 +1431,6 @@ fFlags = [ ( "warn-missing-local-sigs", Opt_WarnMissingLocalSigs, nop ), ( "warn-name-shadowing", Opt_WarnNameShadowing, nop ), ( "warn-overlapping-patterns", Opt_WarnOverlappingPatterns, nop ), - ( "warn-simple-patterns", Opt_WarnSimplePatterns, nop ), ( "warn-type-defaults", Opt_WarnTypeDefaults, nop ), ( "warn-monomorphism-restriction", Opt_WarnMonomorphism, nop ), ( "warn-unused-binds", Opt_WarnUnusedBinds, nop ), @@ -1760,7 +1758,6 @@ minuswRemovesOpts = minusWallOpts ++ [Opt_WarnImplicitPrelude, Opt_WarnIncompletePatternsRecUpd, - Opt_WarnSimplePatterns, Opt_WarnMonomorphism, Opt_WarnUnrecognisedPragmas, Opt_WarnTabs diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml index 9b26e49..5a3458a 100644 --- a/docs/users_guide/flags.xml +++ b/docs/users_guide/flags.xml @@ -1179,13 +1179,6 @@ - - warn about lambda-patterns that can fail - dynamic - - - - warn if there are tabs in the source file dynamic diff --git a/docs/users_guide/using.xml b/docs/users_guide/using.xml index 593781f..7ef2f2f 100644 --- a/docs/users_guide/using.xml +++ b/docs/users_guide/using.xml @@ -989,7 +989,6 @@ ghc -c Foo.hs suspicious code. The warnings that are not enabled by are - , , , , @@ -1376,28 +1375,6 @@ f "2" = 2 - : - - - - Causes the compiler to warn about lambda-bound - patterns that can fail, eg. \(x:xs)->.... - Normally, these aren't treated as incomplete patterns by - . - “Lambda-bound patterns” includes all places where there is a single pattern, - including list comprehensions and do-notation. In these cases, a pattern-match - failure is quite legitimate, and triggers filtering (list comprehensions) or - the monad fail operation (monads). For example: - - f :: [Maybe a] -> [a] - f xs = [y | Just y <- xs] - - Switching on will elicit warnings about - these probably-innocent cases, which is why the flag is off by default. - - - - :