[commit: ghc] ghc-7.10: Make mkQualPackage more robust when package key is bad. (c808656)

git at git.haskell.org git at git.haskell.org
Fri Jul 10 09:37:35 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/c808656bc4c5c37057088b8ac45b40749ce98e0b/ghc

>---------------------------------------------------------------

commit c808656bc4c5c37057088b8ac45b40749ce98e0b
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date:   Thu Jul 9 10:21:51 2015 -0700

    Make mkQualPackage more robust when package key is bad.
    
    Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
    
    Test Plan: validate
    
    Reviewers: bgamari, austin
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1060
    
    GHC Trac Issues: #10624


>---------------------------------------------------------------

c808656bc4c5c37057088b8ac45b40749ce98e0b
 compiler/main/HscTypes.hs | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs
index 02592a3..dfc394d 100644
--- a/compiler/main/HscTypes.hs
+++ b/compiler/main/HscTypes.hs
@@ -1588,15 +1588,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 at 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.



More information about the ghc-commits mailing list