From dc9961f9da0831fe3bc5b55722dac638635f8b5e Mon Sep 17 00:00:00 2001
From: Simon Peyton Jones <simonpj@microsoft.com>
Date: Wed, 23 Oct 2013 12:10:48 +0100
Subject: [PATCH] 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
---
 compiler/rename/RnPat.lhs | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/compiler/rename/RnPat.lhs b/compiler/rename/RnPat.lhs
index 76b7d9004607..16f94fe5a8d5 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
-- 
GitLab