summaryrefslogtreecommitdiff
path: root/compiler/rename
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rename')
-rw-r--r--compiler/rename/RnBinds.hs6
-rw-r--r--compiler/rename/RnNames.hs11
-rw-r--r--compiler/rename/RnSource.hs2
3 files changed, 12 insertions, 7 deletions
diff --git a/compiler/rename/RnBinds.hs b/compiler/rename/RnBinds.hs
index 1af93f35d2..edbcc9cf05 100644
--- a/compiler/rename/RnBinds.hs
+++ b/compiler/rename/RnBinds.hs
@@ -436,12 +436,12 @@ rnBindLHS name_maker _ bind@(FunBind { fun_id = name@(L nameLoc _) })
; return (bind { fun_id = L nameLoc newname
, bind_fvs = placeHolderNamesTc }) }
-rnBindLHS name_maker _ (PatSynBind psb@PSB{ psb_id = rdrname@(L nameLoc _) })
+rnBindLHS name_maker _ (PatSynBind psb@PSB{ psb_id = rdrname })
= do { unless (isTopRecNameMaker name_maker) $
addErr localPatternSynonymErr
; addLocM checkConName rdrname
- ; name <- applyNameMaker name_maker rdrname
- ; return (PatSynBind psb{ psb_id = L nameLoc name }) }
+ ; name <- lookupLocatedTopBndrRn rdrname
+ ; return (PatSynBind psb{ psb_id = name }) }
where
localPatternSynonymErr :: SDoc
localPatternSynonymErr
diff --git a/compiler/rename/RnNames.hs b/compiler/rename/RnNames.hs
index bff2ed0f29..237e6c3a46 100644
--- a/compiler/rename/RnNames.hs
+++ b/compiler/rename/RnNames.hs
@@ -40,6 +40,7 @@ import ErrUtils
import Util
import FastString
import ListSetOps
+import Bag
import Control.Monad
import Data.Map ( Map )
@@ -507,11 +508,11 @@ getLocalNonValBinders fixity_env
; nti_avails <- concatMapM new_assoc inst_decls
-- Finish off with value binders:
- -- foreign decls for an ordinary module
+ -- foreign decls and pattern synonyms for an ordinary module
-- type sigs in case of a hs-boot file only
; is_boot <- tcIsHsBootOrSig
; let val_bndrs | is_boot = hs_boot_sig_bndrs
- | otherwise = for_hs_bndrs
+ | otherwise = for_hs_bndrs ++ patsyn_hs_bndrs
; val_avails <- mapM new_simple val_bndrs
; let avails = nti_avails ++ val_avails
@@ -525,11 +526,15 @@ getLocalNonValBinders fixity_env
for_hs_bndrs = [ L decl_loc (unLoc nm)
| L decl_loc (ForeignImport nm _ _ _) <- foreign_decls]
+ patsyn_hs_bndrs :: [Located RdrName]
+ patsyn_hs_bndrs = [ L decl_loc (unLoc n)
+ | L decl_loc (PatSynBind PSB{ psb_id = n }) <- bagToList val_bag]
+
-- In a hs-boot file, the value binders come from the
-- *signatures*, and there should be no foreign binders
hs_boot_sig_bndrs = [ L decl_loc (unLoc n)
| L decl_loc (TypeSig ns _ _) <- val_sigs, n <- ns]
- ValBindsIn _ val_sigs = val_binds
+ ValBindsIn val_bag val_sigs = val_binds
-- the SrcSpan attached to the input should be the span of the
-- declaration, not just the name
diff --git a/compiler/rename/RnSource.hs b/compiler/rename/RnSource.hs
index 95211cbdfc..4395329493 100644
--- a/compiler/rename/RnSource.hs
+++ b/compiler/rename/RnSource.hs
@@ -114,7 +114,7 @@ rnSrcDecls extra_deps group@(HsGroup { hs_valds = val_decls,
-- It uses the fixity env from (A) to bind fixities for view patterns.
new_lhs <- rnTopBindsLHS local_fix_env val_decls ;
-- bind the LHSes (and their fixities) in the global rdr environment
- let { val_binders = collectHsValBinders new_lhs ;
+ let { val_binders = collectHsValNewBinders new_lhs ;
all_bndrs = extendNameSetList tc_bndrs val_binders ;
val_avails = map Avail val_binders } ;
traceRn (text "rnSrcDecls" <+> ppr val_avails) ;