diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-11-17 21:23:52 -0800 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-11-29 23:16:31 -0800 |
commit | 4c834fdddf4d44d12039da4d6a2c63a660975b95 (patch) | |
tree | 58c18fc03de10b2832ca62655dbba4cd833cec95 /testsuite/tests/ghci/scripts/T2182ghci2.script | |
parent | 46c53d5ce5a1d00f29ffea0c3741d972e4beab97 (diff) | |
download | haskell-4c834fdddf4d44d12039da4d6a2c63a660975b95.tar.gz |
Filter instance visibility based on set of visible orphans, fixes #2182.ghc-instvis
Summary:
Amazingly, the fix for this very old bug is quite simple: when type-checking,
maintain a set of "visible orphan modules" based on the orphans list of
modules which we explicitly imported. When we import an instance and it
is an orphan, we check if it is in the visible modules set, and if not,
ignore it. A little bit of refactoring for when orphan-hood is calculated
happens so that we always know if an instance is an orphan or not.
For GHCi, we preinitialize the visible modules set based on the list of
interactive imports which are active.
Future work: Cache the visible orphan modules set for GHCi, rather than
recomputing it every type-checking round. (But it's tricky what to do when you
/remove/ a module: you need a data structure a little more complicated than
just a set of modules.)
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: new tests and validate
Reviewers: simonpj, austin
Subscribers: thomie, carter
Differential Revision: https://phabricator.haskell.org/D488
GHC Trac Issues: #2182
Diffstat (limited to 'testsuite/tests/ghci/scripts/T2182ghci2.script')
-rw-r--r-- | testsuite/tests/ghci/scripts/T2182ghci2.script | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/scripts/T2182ghci2.script b/testsuite/tests/ghci/scripts/T2182ghci2.script new file mode 100644 index 0000000000..7bb4791140 --- /dev/null +++ b/testsuite/tests/ghci/scripts/T2182ghci2.script @@ -0,0 +1,15 @@ +-- Warning: this test will stop working when we eliminate orphans from +-- GHC.Float. The idea of this test is to import an external package +-- module which transitively depends on the module defining the orphan +-- instance. +:m +GHC.Types +"NO" +0.2 :: Float + +:m +Prelude +"YES" +0.2 :: Float + +:m -Prelude +"NO" +0.2 :: Float |