
Or GHC could not warn on too many guards, because it's really a warning
#11316: Too many guards warning causes issues -------------------------------------+------------------------------------- Reporter: NeilMitchell | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * priority: normal => high * cc: gkaracha (added) * milestone: => 8.0.1 Comment: that the compiler can't cope, not that too many guards is necessarily bad. Indeed I'm quite uncertain of the right way forward here as all options are quite bad, On one hand, remaining silent in this case means that the user may rely on the compiler's pattern checker when it can't be relied upon. In passing `-Wall` to GHC, the user has requested that we provide warnings on non- exhaustive patterns. If we can't deliver on this promise it seems to me that we have a duty to ensure that the user knows this. To remain silent will mean that users may be taken by surprise when their warning-free code nevertheless crashes. For this reason I think it is quite important that a warning of this sort is available (although perhaps not enabled by default). Of course, this is made slightly trickier by the fact that pattern match checking is a hard problem and therefore will always be approximate. Moreover, before George's work we couldn't reason about guards at all. Further, even now the check necessarily breaks down completely in the face of boolean guards. Moreover, I am sympathetic to the complaint that it is too difficult to disable this warning in the presence of multiple compiler versions. == A pragma? == Our current approach to this issue, the `-Wtoo-many-guards` warning, has always been a bit of a compromise. For one, it is far too coarse-grained. In an ideal world, I would say that this flag ought to be a pragma attached to a particular binding, which would solve several problems, * someone reading or modifying the binding will be faced with a reminder that they cannot count on full pattern checking * one doesn't need to completely give up on full pattern checking in a module on account of a single large binding Unfortunately the fact that unknown pragmas are errors with `-Werror` makes this option just as inconvenient as the current flag. == A Proposal == Given the fact that guard checking is merely nice to have and will always be approximate, I tend to think we should just disable this warning by default. Hopefully for 8.2 we will have a [[https://ghc.haskell.org/trac/ghc/wiki/Design/Warnings#ProposedChange|richer scheme]] for managing warnings, at which point we can add `-Wtoo-many- warnings` to `-Weverything`. In the meantime, we'll just need to ensure that the user's guide makes it known that the user must enable this flag if they want to be notified when the pattern checker gives up. George, what do you think? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11316#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler