Skip to content

Commit

Permalink
Fix type variable scoping in nested pattern type signatures (#7827)
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Palka authored and Simon Peyton Jones committed Apr 12, 2013
1 parent 6afa777 commit 37be6f0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions compiler/rename/RnPat.lhs
Expand Up @@ -330,8 +330,17 @@ rnPatAndThen mk (VarPat rdr) = do { loc <- liftCps getSrcSpanM
-- (e.g. in the pattern (x, x -> y) x needs to be bound in the rhs of the tuple)
rnPatAndThen mk (SigPatIn pat sig)
= do { pat' <- rnLPatAndThen mk pat
; sig' <- rnHsSigCps sig
-- When renaming a pattern type signature (e.g. f (a :: T) = ...), it is
-- important to rename its type signature _before_ renaming the rest of the
-- pattern, so that type variables are first bound by the _outermost_ pattern
-- type signature they occur in. This keeps the type checker happy when
-- pattern type signatures happen to be nested (#7827)
--
-- f ((Just (x :: a) :: Maybe a)
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~^ `a' is first bound here
-- ~~~~~~~~~~~~~~~^ the same `a' then used here
= do { sig' <- rnHsSigCps sig
; pat' <- rnLPatAndThen mk pat
; return (SigPatIn pat' sig') }
rnPatAndThen mk (LitPat lit)
Expand Down

0 comments on commit 37be6f0

Please sign in to comment.