diff options
| author | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-08-22 09:28:49 -0400 |
|---|---|---|
| committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-08-22 09:28:49 -0400 |
| commit | a89bb806c58d3e601b37d6f2c4ebec6514fd2776 (patch) | |
| tree | b2bef8ba5b726ac2ef726ec29eee5d6b592a93b8 /compiler/rename | |
| parent | 6982ee99fb97c252c3faf37faae34131fb66f67c (diff) | |
| download | haskell-a89bb806c58d3e601b37d6f2c4ebec6514fd2776.tar.gz | |
Fix #14114 by checking for duplicate vars on pattern synonym RHSes
Summary:
Because we weren't checking for duplicate variables on the right-hand
sides of pattern synonyms, bogus definitions like this one passed the renamer:
```lang=haskell
pattern Foo a <- (a,a)
```
Luckily, the fix is simple.
Test Plan: make test TEST=T14114
Reviewers: mpickering, austin, bgamari, simonpj
Reviewed By: simonpj
Subscribers: simonpj, rwbarton, thomie
GHC Trac Issues: #14114
Differential Revision: https://phabricator.haskell.org/D3866
Diffstat (limited to 'compiler/rename')
| -rw-r--r-- | compiler/rename/RnPat.hs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rename/RnPat.hs b/compiler/rename/RnPat.hs index 320e4f3d12..9b439a7b19 100644 --- a/compiler/rename/RnPat.hs +++ b/compiler/rename/RnPat.hs @@ -47,8 +47,8 @@ import RnEnv import RnFixity import RnUtils ( HsDocContext(..), newLocalBndrRn, bindLocalNames , warnUnusedMatches, newLocalBndrRn - , checkDupAndShadowedNames, checkTupSize - , unknownSubordinateErr ) + , checkDupNames, checkDupAndShadowedNames + , checkTupSize , unknownSubordinateErr ) import RnTypes import PrelNames import TyCon ( tyConName ) @@ -67,7 +67,7 @@ import TysWiredIn ( nilDataCon ) import DataCon import qualified GHC.LanguageExtensions as LangExt -import Control.Monad ( when, liftM, ap, unless ) +import Control.Monad ( when, liftM, ap ) import qualified Data.List.NonEmpty as NE import Data.Ratio @@ -321,10 +321,11 @@ rnPats ctxt pats thing_inside -- complain *twice* about duplicates e.g. f (x,x) = ... -- -- See note [Don't report shadowing for pattern synonyms] - ; unless (isPatSynCtxt ctxt) - (addErrCtxt doc_pat $ - checkDupAndShadowedNames envs_before $ - collectPatsBinders pats') + ; let bndrs = collectPatsBinders pats' + ; addErrCtxt doc_pat $ + if isPatSynCtxt ctxt + then checkDupNames bndrs + else checkDupAndShadowedNames envs_before bndrs ; thing_inside pats' } } where doc_pat = text "In" <+> pprMatchContext ctxt |
