[commit: ghc] master: GHCi: Improve the error message for hidden packages (721e826)
git at git.haskell.org
git at git.haskell.org
Thu May 3 19:21:54 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/721e82644b49da59e84c409562a63e7df75068bb/ghc
>---------------------------------------------------------------
commit 721e82644b49da59e84c409562a63e7df75068bb
Author: Chaitanya Koparkar <ckoparkar at gmail.com>
Date: Thu May 3 12:39:45 2018 -0400
GHCi: Improve the error message for hidden packages
Test Plan: make test TEST=T15055
Reviewers: bgamari, RyanGlScott, osa1, Iceland_jack
Reviewed By: osa1
Subscribers: ulysses4ever, thomie, carter
GHC Trac Issues: #15055
Differential Revision: https://phabricator.haskell.org/D4621
>---------------------------------------------------------------
721e82644b49da59e84c409562a63e7df75068bb
compiler/main/Finder.hs | 10 +++++++---
testsuite/tests/ghci/should_fail/T15055.script | 1 +
testsuite/tests/ghci/should_fail/T15055.stderr | 5 +++++
testsuite/tests/ghci/should_fail/all.T | 1 +
testsuite/tests/package/package01e.stderr | 2 ++
testsuite/tests/package/package06e.stderr | 2 ++
testsuite/tests/package/package07e.stderr | 3 +++
testsuite/tests/package/package08e.stderr | 3 +++
testsuite/tests/plugins/T11244.stderr | 1 +
9 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/compiler/main/Finder.hs b/compiler/main/Finder.hs
index 2bfea5d..9568ac1 100644
--- a/compiler/main/Finder.hs
+++ b/compiler/main/Finder.hs
@@ -667,14 +667,18 @@ cantFindErr cannot_find _ dflags mod_name find_result
<+> quotes (ppr pkgid)
--FIXME: we don't really want to show the unit id here we should
-- show the source package id or installed package id if it's ambiguous
- <> dot $$ cabal_pkg_hidden_hint pkgid
- cabal_pkg_hidden_hint pkgid
+ <> dot $$ pkg_hidden_hint pkgid
+ pkg_hidden_hint pkgid
| gopt Opt_BuildingCabalPackage dflags
= let pkg = expectJust "pkg_hidden" (lookupPackage dflags pkgid)
in text "Perhaps you need to add" <+>
quotes (ppr (packageName pkg)) <+>
text "to the build-depends in your .cabal file."
- | otherwise = Outputable.empty
+ | otherwise
+ = let pkg = expectJust "pkg_hidden" (lookupPackage dflags pkgid)
+ in text "You can run" <+>
+ quotes (text ":set -package " <> ppr (packageName pkg)) <+>
+ text "to expose it."
mod_hidden pkg =
text "it is a hidden module in the package" <+> quotes (ppr pkg)
diff --git a/testsuite/tests/ghci/should_fail/T15055.script b/testsuite/tests/ghci/should_fail/T15055.script
new file mode 100644
index 0000000..800944a
--- /dev/null
+++ b/testsuite/tests/ghci/should_fail/T15055.script
@@ -0,0 +1 @@
+import GHC
diff --git a/testsuite/tests/ghci/should_fail/T15055.stderr b/testsuite/tests/ghci/should_fail/T15055.stderr
new file mode 100644
index 0000000..dcc297c
--- /dev/null
+++ b/testsuite/tests/ghci/should_fail/T15055.stderr
@@ -0,0 +1,5 @@
+
+<no location info>:
+ Could not find module ‘GHC’
+ It is a member of the hidden package ‘ghc-8.5’.
+ You can run ‘:set -package ghc’ to expose it.
diff --git a/testsuite/tests/ghci/should_fail/all.T b/testsuite/tests/ghci/should_fail/all.T
index 2851373..d62c3ba 100644
--- a/testsuite/tests/ghci/should_fail/all.T
+++ b/testsuite/tests/ghci/should_fail/all.T
@@ -1,3 +1,4 @@
test('T10549', [], ghci_script, ['T10549.script'])
test('T10549a', [], ghci_script, ['T10549a.script'])
test('T14608', [], ghci_script, ['T14608.script'])
+test('T15055', [], ghci_script, ['T15055.script'])
diff --git a/testsuite/tests/package/package01e.stderr b/testsuite/tests/package/package01e.stderr
index 7dd9f69..a755991 100644
--- a/testsuite/tests/package/package01e.stderr
+++ b/testsuite/tests/package/package01e.stderr
@@ -2,9 +2,11 @@
package01e.hs:2:1: error:
Could not find module ‘Data.Map’
It is a member of the hidden package ‘containers-0.5.11.0’.
+ You can run ‘:set -package containers’ to expose it.
Use -v to see a list of the files searched for.
package01e.hs:3:1: error:
Could not find module ‘Data.IntMap’
It is a member of the hidden package ‘containers-0.5.11.0’.
+ You can run ‘:set -package containers’ to expose it.
Use -v to see a list of the files searched for.
diff --git a/testsuite/tests/package/package06e.stderr b/testsuite/tests/package/package06e.stderr
index c634d2d..59aeb37 100644
--- a/testsuite/tests/package/package06e.stderr
+++ b/testsuite/tests/package/package06e.stderr
@@ -2,9 +2,11 @@
package06e.hs:2:1: error:
Could not find module ‘HsTypes’
It is a member of the hidden package ‘ghc-8.1’.
+ You can run ‘:set -package ghc’ to expose it.
Use -v to see a list of the files searched for.
package06e.hs:3:1: error:
Could not find module ‘UniqFM’
It is a member of the hidden package ‘ghc-8.1’.
+ You can run ‘:set -package ghc’ to expose it.
Use -v to see a list of the files searched for.
diff --git a/testsuite/tests/package/package07e.stderr b/testsuite/tests/package/package07e.stderr
index 9ca835f..d167508 100644
--- a/testsuite/tests/package/package07e.stderr
+++ b/testsuite/tests/package/package07e.stderr
@@ -7,14 +7,17 @@ package07e.hs:2:1: error:
package07e.hs:3:1: error:
Could not find module ‘HsTypes’
It is a member of the hidden package ‘ghc-8.5’.
+ You can run ‘:set -package ghc’ to expose it.
Use -v to see a list of the files searched for.
package07e.hs:4:1: error:
Could not find module ‘HsUtils’
It is a member of the hidden package ‘ghc-8.5’.
+ You can run ‘:set -package ghc’ to expose it.
Use -v to see a list of the files searched for.
package07e.hs:5:1: error:
Could not find module ‘UniqFM’
It is a member of the hidden package ‘ghc-8.5’.
+ You can run ‘:set -package ghc’ to expose it.
Use -v to see a list of the files searched for.
diff --git a/testsuite/tests/package/package08e.stderr b/testsuite/tests/package/package08e.stderr
index 5992a4c..922c643 100644
--- a/testsuite/tests/package/package08e.stderr
+++ b/testsuite/tests/package/package08e.stderr
@@ -7,14 +7,17 @@ package08e.hs:2:1: error:
package08e.hs:3:1: error:
Could not find module ‘HsTypes’
It is a member of the hidden package ‘ghc-8.5’.
+ You can run ‘:set -package ghc’ to expose it.
Use -v to see a list of the files searched for.
package08e.hs:4:1: error:
Could not find module ‘HsUtils’
It is a member of the hidden package ‘ghc-8.5’.
+ You can run ‘:set -package ghc’ to expose it.
Use -v to see a list of the files searched for.
package08e.hs:5:1: error:
Could not find module ‘UniqFM’
It is a member of the hidden package ‘ghc-8.5’.
+ You can run ‘:set -package ghc’ to expose it.
Use -v to see a list of the files searched for.
diff --git a/testsuite/tests/plugins/T11244.stderr b/testsuite/tests/plugins/T11244.stderr
index 30c8c5b..472ef44 100644
--- a/testsuite/tests/plugins/T11244.stderr
+++ b/testsuite/tests/plugins/T11244.stderr
@@ -1,3 +1,4 @@
<command line>: Could not find module ‘RuleDefiningPlugin’
It is a member of the hidden package ‘rule-defining-plugin-0.1’.
+You can run ‘:set -package rule-defining-plugin’ to expose it.
Use -v to see a list of the files searched for.
More information about the ghc-commits
mailing list