diff options
| author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-12-27 23:57:18 +0100 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2015-12-27 23:57:19 +0100 |
| commit | 1b0001680ef66a2853103974d3f3f956bb0560a3 (patch) | |
| tree | 76462be00b762ae1ff08e024f76b93f534bba36e /compiler/main/Packages.hs | |
| parent | c8d0af3107d4a01b73f813e31ac9b989772a2288 (diff) | |
| download | haskell-1b0001680ef66a2853103974d3f3f956bb0560a3.tar.gz | |
The -package flag should select match from right-most package db.
The shadowing and default behavior (in the absence of
-hide-all-packages) prefers packages that come from "later" package
databases. So for example if tmp1.d and tmp2.d both expose p-1.0, then
ghc -package-db tmp1.d -package-db tmp2.d
brings the p-1.0 from tmp2.d into scope (and if they have the same IPID,
tmp2.d shadows tmp1.d). HOWEVER, -package flags do NOT respect this
behavior.
ghc -package-db tmp1.d -package-db tmp2.d -package p-1.0
this will force the p-1.0 from tmp1.d to be exposed! This is
confusing, so this patch makes the behavior of -package flags
consistent.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1709
Diffstat (limited to 'compiler/main/Packages.hs')
| -rw-r--r-- | compiler/main/Packages.hs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs index 2849b7e70a..f7bff71f1f 100644 --- a/compiler/main/Packages.hs +++ b/compiler/main/Packages.hs @@ -593,7 +593,9 @@ selectPackages matches pkgs unusable = let (ps,rest) = partition matches pkgs in if null ps then Left (filter (matches.fst) (Map.elems unusable)) - else Right (sortByVersion ps, rest) + -- NB: packages from later package databases are LATER + -- in the list. We want to prefer the latest package. + else Right (sortByVersion (reverse ps), rest) -- A package named on the command line can either include the -- version, or just the name if it is unambiguous. |
