summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2013-10-23 12:10:48 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2013-10-23 12:10:48 +0100
commitdc9961f9da0831fe3bc5b55722dac638635f8b5e (patch)
tree2ad3cb19c4e6dad3f847fa7756ef035ef0595f31
parent97dfa2fe36933339ceb58bff9a231a78aa1fe2c3 (diff)
downloadhaskell-dc9961f9da0831fe3bc5b55722dac638635f8b5e.tar.gz
Fix Trac #8448
We weren't dealing with built-in syntax; data constructors that are built-in syntax (only [] actually) don't appear in the GlobalRdrEnv
-rw-r--r--compiler/rename/RnPat.lhs14
1 files changed, 11 insertions, 3 deletions
diff --git a/compiler/rename/RnPat.lhs b/compiler/rename/RnPat.lhs
index 76b7d90046..16f94fe5a8 100644
--- a/compiler/rename/RnPat.lhs
+++ b/compiler/rename/RnPat.lhs
@@ -53,6 +53,9 @@ import RnEnv
import RnTypes
import DynFlags
import PrelNames
+import TyCon ( tyConName )
+import DataCon ( dataConTyCon )
+import TypeRep ( TyThing(..) )
import Name
import NameSet
import RdrName
@@ -609,9 +612,14 @@ rnHsRecFields1 ctxt mk_arg (HsRecFields { rec_flds = flds, rec_dotdot = dotdot }
-- That is, the parent of the data constructor.
-- That's the parent to use for looking up record fields.
find_tycon env con
- = case lookupGRE_Name env con of
- [GRE { gre_par = ParentIs p }] -> p
- gres -> pprPanic "find_tycon" (ppr con $$ ppr gres)
+ | Just (ADataCon dc) <- wiredInNameTyThing_maybe con
+ = tyConName (dataConTyCon dc) -- Special case for [], which is built-in syntax
+ -- and not in the GlobalRdrEnv (Trac #8448)
+ | [GRE { gre_par = ParentIs p }] <- lookupGRE_Name env con
+ = p
+
+ | otherwise
+ = pprPanic "find_tycon" (ppr con $$ ppr (lookupGRE_Name env con))
dup_flds :: [[RdrName]]
-- Each list represents a RdrName that occurred more than once