-fwarn-irrefutable-patterns
Had a search around and didn't see such a request, apologies if already proposed.
Would it be possible and make sense to warn when an irrefutable pattern has more than one case? Example:
data Query = GetTheStuff Int
foo x = bar where
GetTheStuff n = x
If I (or someone else) later go and add a new constructor to GetTheStuff, I'm not made aware of this use here. Obviously irrefutable patterns should only be used for things with one data structure (or if you're bold enough to think the other case won't happen—I'm more paranoid).
This has bitten me only a couple times, probably others only a few times. Maybe it's not a huge deal? But if it's really trivial to add, could be nice? I'm just proposing this here. I might try implementing it myself, it sounds easy.
Trac metadata
Trac field | Value |
---|---|
Version | 7.6.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |