summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorAdam Gundry <adam@well-typed.com>2016-06-18 12:27:47 +0200
committerBen Gamari <ben@smart-cactus.org>2016-06-19 00:27:06 +0200
commit4d71cc89b4e9648f3fbb29c8fcd25d725616e265 (patch)
tree8f49d476bdc4dd4085676e7e12744c7bdb72b74a /compiler
parent9649fc0ae45e006c2ed54cc5ea2414158949fadb (diff)
downloadhaskell-4d71cc89b4e9648f3fbb29c8fcd25d725616e265.tar.gz
Avoid find_tycon panic if datacon is not in scope
When using TH to splice expressions involving record field construction, the parent datacon may not be in scope. We shouldn't panic about this, because we will be renaming Exact RdrNames which don't require any disambiguation. Test Plan: new test th/T12130 Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2321 GHC Trac Issues: #12130
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rename/RnPat.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rename/RnPat.hs b/compiler/rename/RnPat.hs
index 98ca38bf66..d252f7fef0 100644
--- a/compiler/rename/RnPat.hs
+++ b/compiler/rename/RnPat.hs
@@ -635,7 +635,7 @@ rnHsRecFields ctxt mk_arg (HsRecFields { rec_flds = flds, rec_dotdot = dotdot })
find_tycon :: GlobalRdrEnv -> Name {- DataCon -} -> Maybe Name {- TyCon -}
-- Return the parent *type constructor* of the data constructor
-- (that is, the parent of the data constructor),
- -- or 'Nothing' if it is a pattern synonym.
+ -- or 'Nothing' if it is a pattern synonym or not in scope.
-- That's the parent to use for looking up record fields.
find_tycon env con
| Just (AConLike (RealDataCon dc)) <- wiredInNameTyThing_maybe con
@@ -647,8 +647,9 @@ rnHsRecFields ctxt mk_arg (HsRecFields { rec_flds = flds, rec_dotdot = dotdot })
ParentIs p -> Just p
_ -> Nothing
- | otherwise
- = pprPanic "find_tycon" (ppr con $$ ppr (lookupGRE_Name env con))
+ | otherwise = Nothing
+ -- This can happen if the datacon is not in scope
+ -- and we are in a TH splice (Trac #12130)
dup_flds :: [[RdrName]]
-- Each list represents a RdrName that occurred more than once