The -package flag should select match from right-most package db.
authorEdward Z. Yang <ezyang@cs.stanford.edu>
Sun, 27 Dec 2015 22:57:18 +0000 (23:57 +0100)
committerBen Gamari <ben@smart-cactus.org>
Sun, 27 Dec 2015 22:57:19 +0000 (23:57 +0100)
commit1b0001680ef66a2853103974d3f3f956bb0560a3
tree76462be00b762ae1ff08e024f76b93f534bba36e
parentc8d0af3107d4a01b73f813e31ac9b989772a2288
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
17 files changed:
compiler/main/Packages.hs
testsuite/.gitignore
testsuite/tests/cabal/cabal08/Main.hs [new file with mode: 0644]
testsuite/tests/cabal/cabal08/Makefile [new file with mode: 0644]
testsuite/tests/cabal/cabal08/Setup.hs [new file with mode: 0644]
testsuite/tests/cabal/cabal08/all.T [new file with mode: 0644]
testsuite/tests/cabal/cabal08/cabal08.stdout [new file with mode: 0644]
testsuite/tests/cabal/cabal08/p1/ChangeLog.md [new file with mode: 0644]
testsuite/tests/cabal/cabal08/p1/LICENSE [new file with mode: 0644]
testsuite/tests/cabal/cabal08/p1/P.hs [new file with mode: 0644]
testsuite/tests/cabal/cabal08/p1/Setup.hs [new file with mode: 0644]
testsuite/tests/cabal/cabal08/p1/p.cabal [new file with mode: 0644]
testsuite/tests/cabal/cabal08/p2/ChangeLog.md [new file with mode: 0644]
testsuite/tests/cabal/cabal08/p2/LICENSE [new file with mode: 0644]
testsuite/tests/cabal/cabal08/p2/P.hs [new file with mode: 0644]
testsuite/tests/cabal/cabal08/p2/Setup.hs [new file with mode: 0644]
testsuite/tests/cabal/cabal08/p2/p.cabal [new file with mode: 0644]