diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-07-09 10:21:51 -0700 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-07-09 11:05:06 -0700 |
commit | 6f1c0766943cdb9a567c0e2b9d41c5e73c2ff5bc (patch) | |
tree | 0aa521c2622179a2b7748590062a8f5a4d0b11d5 | |
parent | a6359f2629024d67fc82a7d41c67d5d89d2d3a3d (diff) | |
download | haskell-6f1c0766943cdb9a567c0e2b9d41c5e73c2ff5bc.tar.gz |
Make mkQualPackage more robust when package key is bad.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: bgamari, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1060
GHC Trac Issues: #10624
-rw-r--r-- | compiler/main/HscTypes.hs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs index c2a5153a4a..b7707f80af 100644 --- a/compiler/main/HscTypes.hs +++ b/compiler/main/HscTypes.hs @@ -1620,15 +1620,14 @@ mkQualPackage dflags pkg_key -- Skip the lookup if it's main, since it won't be in the package -- database! = False - | searchPackageId dflags pkgid `lengthIs` 1 + | Just pkgid <- mb_pkgid + , searchPackageId dflags pkgid `lengthIs` 1 -- this says: we are given a package pkg-0.1@MMM, are there only one -- exposed packages whose package ID is pkg-0.1? = False | otherwise = True - where pkg = fromMaybe (pprPanic "qual_pkg" (ftext (packageKeyFS pkg_key))) - (lookupPackage dflags pkg_key) - pkgid = sourcePackageId pkg + where mb_pkgid = fmap sourcePackageId (lookupPackage dflags pkg_key) -- | A function which only qualifies package names if necessary; but -- qualifies all other identifiers. |