[commit: ghc] master: Emit addUsedRdrNames for the datacons in a standalone deriving (Trac #7969) (b2cde43)
Simon Peyton Jones
simonpj at microsoft.com
Tue Jun 18 09:35:04 CEST 2013
Repository : http://darcs.haskell.org/ghc.git/
On branch : master
https://github.com/ghc/ghc/commit/b2cde434bbf3060dc5eda39876e4c9180aea1d1a
>---------------------------------------------------------------
commit b2cde434bbf3060dc5eda39876e4c9180aea1d1a
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Mon Jun 17 22:45:28 2013 +0100
Emit addUsedRdrNames for the datacons in a standalone deriving (Trac #7969)
>---------------------------------------------------------------
compiler/typecheck/TcDeriv.lhs | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/compiler/typecheck/TcDeriv.lhs b/compiler/typecheck/TcDeriv.lhs
index fb3e7ee..e9f6d28 100644
--- a/compiler/typecheck/TcDeriv.lhs
+++ b/compiler/typecheck/TcDeriv.lhs
@@ -704,10 +704,22 @@ mkEqnHelp orig tvs cls cls_tys tc_app mtheta
-- For standalone deriving (mtheta /= Nothing),
-- check that all the data constructors are in scope.
; rdr_env <- getGlobalRdrEnv
- ; let hidden_data_cons = not (isWiredInName (tyConName rep_tc)) &&
+ ; let data_con_names = map dataConName (tyConDataCons rep_tc)
+ hidden_data_cons = not (isWiredInName (tyConName rep_tc)) &&
(isAbstractTyCon rep_tc ||
- any not_in_scope (tyConDataCons rep_tc))
- not_in_scope dc = null (lookupGRE_Name rdr_env (dataConName dc))
+ any not_in_scope data_con_names)
+ not_in_scope dc = null (lookupGRE_Name rdr_env dc)
+
+ -- Make a Qual RdrName that will do for each DataCon
+ -- so we can report it as used (Trac #7969)
+ data_con_rdrs = [ mkRdrQual (is_as (is_decl imp_spec)) occ
+ | dc_name <- data_con_names
+ , let occ = nameOccName dc_name
+ gres = lookupGRE_Name rdr_env dc_name
+ , not (null gres)
+ , Imported (imp_spec:_) <- [gre_prov (head gres)] ]
+
+ ; addUsedRdrNames data_con_rdrs
; unless (isNothing mtheta || not hidden_data_cons)
(bale_out (derivingHiddenErr tycon))
More information about the ghc-commits
mailing list