From: igloo Date: Mon, 18 Oct 2004 18:25:06 +0000 (+0000) Subject: [project @ 2004-10-18 18:24:59 by igloo] X-Git-Tag: Initial_conversion_from_CVS_complete~1492 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=79d7a7c0d17b51dfb2bb06d758b6e556550862ba [project @ 2004-10-18 18:24:59 by igloo] Implement -fwarn-incomplete-record-updates --- diff --git a/ghc/compiler/deSugar/Match.lhs b/ghc/compiler/deSugar/Match.lhs index 7626360..ebe503a 100644 --- a/ghc/compiler/deSugar/Match.lhs +++ b/ghc/compiler/deSugar/Match.lhs @@ -67,8 +67,12 @@ matchCheck_really dflags ctx vars ty qs | otherwise = match vars ty qs where (pats, eqns_shadow) = check qs - incomplete = dopt Opt_WarnIncompletePatterns dflags - && (notNull pats) + incomplete = want_incomplete && (notNull pats) + want_incomplete = case ctx of + DsMatchContext RecUpd _ _ -> + dopt Opt_WarnIncompletePatternsRecUpd dflags + _ -> + dopt Opt_WarnIncompletePatterns dflags shadow = dopt Opt_WarnOverlappingPatterns dflags && not (null eqns_shadow) \end{code} diff --git a/ghc/compiler/main/CmdLineOpts.lhs b/ghc/compiler/main/CmdLineOpts.lhs index 6042f15..2cf2841 100644 --- a/ghc/compiler/main/CmdLineOpts.lhs +++ b/ghc/compiler/main/CmdLineOpts.lhs @@ -256,6 +256,7 @@ data DynFlag | Opt_WarnDuplicateExports | Opt_WarnHiShadows | Opt_WarnIncompletePatterns + | Opt_WarnIncompletePatternsRecUpd | Opt_WarnMissingFields | Opt_WarnMissingMethods | Opt_WarnMissingSigs diff --git a/ghc/compiler/main/DriverFlags.hs b/ghc/compiler/main/DriverFlags.hs index b3bda23..ac9e92c 100644 --- a/ghc/compiler/main/DriverFlags.hs +++ b/ghc/compiler/main/DriverFlags.hs @@ -441,6 +441,7 @@ fFlags = [ ( "warn-duplicate-exports", Opt_WarnDuplicateExports ), ( "warn-hi-shadowing", Opt_WarnHiShadows ), ( "warn-incomplete-patterns", Opt_WarnIncompletePatterns ), + ( "warn-incomplete-record-updates", Opt_WarnIncompletePatternsRecUpd ), ( "warn-missing-fields", Opt_WarnMissingFields ), ( "warn-missing-methods", Opt_WarnMissingMethods ), ( "warn-missing-signatures", Opt_WarnMissingSigs ), diff --git a/ghc/docs/users_guide/flags.xml b/ghc/docs/users_guide/flags.xml index fb215c7..ab61bd4 100644 --- a/ghc/docs/users_guide/flags.xml +++ b/ghc/docs/users_guide/flags.xml @@ -591,6 +591,13 @@ + + warn when a record update could fail + dynamic + + + + enable miscellaneous warnings dynamic diff --git a/ghc/docs/users_guide/using.xml b/ghc/docs/users_guide/using.xml index 748e0b2..cc4f366 100644 --- a/ghc/docs/users_guide/using.xml +++ b/ghc/docs/users_guide/using.xml @@ -835,6 +835,33 @@ g [] = 2 + : + + + incomplete record updates, warning + record updates, incomplete + + The function + f below will fail when applied to + Bar, so the compiler will emit a warning about + this when is + enabled. + + +data Foo = Foo { x :: Int } + | Bar + +f :: Foo -> Foo +f foo = foo { x = 6 } + + + This option isn't enabled be default because it can be + very noisy, and it often doesn't indicate a bug in the + program. + + + + :