summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2021-03-26 12:01:21 +0100
committerMoritz Angermann <moritz.angermann@gmail.com>2021-03-29 04:03:47 -0400
commitd6cd2055b4bdc5dc97eeebbd24a0e159dd572420 (patch)
tree9df80785450ce3475b0e4e842d093e7427f7848e
parent2754ab55929c5259dcee095b55011d57bd3db61c (diff)
downloadhaskell-d6cd2055b4bdc5dc97eeebbd24a0e159dd572420.tar.gz
More graceful crash in getPackageDetails (#19370)
-rw-r--r--compiler/main/Packages.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs
index 66c46e9d91..c908497542 100644
--- a/compiler/main/Packages.hs
+++ b/compiler/main/Packages.hs
@@ -429,8 +429,9 @@ extendPackageConfigMap (PackageConfigMap pkg_map closure) new_pkgs
-- | Looks up the package with the given id in the package state, panicing if it is
-- not found
getPackageDetails :: DynFlags -> UnitId -> PackageConfig
-getPackageDetails dflags pid =
- expectJust "getPackageDetails" (lookupPackage dflags pid)
+getPackageDetails dflags pid = case lookupPackage dflags pid of
+ Just c -> c
+ Nothing -> pprPanic "getPackageDetails: couldn't find package" (ppr pid)
lookupInstalledPackage :: DynFlags -> InstalledUnitId -> Maybe PackageConfig
lookupInstalledPackage dflags uid = lookupInstalledPackage' (pkgIdMap (pkgState dflags)) uid
@@ -439,9 +440,9 @@ lookupInstalledPackage' :: PackageConfigMap -> InstalledUnitId -> Maybe PackageC
lookupInstalledPackage' (PackageConfigMap db _) uid = lookupUDFM db uid
getInstalledPackageDetails :: DynFlags -> InstalledUnitId -> PackageConfig
-getInstalledPackageDetails dflags uid =
- expectJust "getInstalledPackageDetails" $
- lookupInstalledPackage dflags uid
+getInstalledPackageDetails dflags uid = case lookupInstalledPackage dflags uid of
+ Just c -> c
+ Nothing -> pprPanic "getInstalledPackageDetails: couldn't find package" (ppr uid)
-- | Get a list of entries from the package database. NB: be careful with
-- this function, although all packages in this map are "visible", this