summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/T9497a.stderr
diff options
context:
space:
mode:
authorMatthías Páll Gissurarson <mpg@mpg.is>2017-09-21 14:14:53 -0400
committerBen Gamari <ben@smart-cactus.org>2017-09-21 14:53:32 -0400
commit1c9208323b5ccd6796d00763ccba9d3b4a612358 (patch)
tree27aed28308a032cd0f78a4c5b90fabc50e18cd1b /testsuite/tests/typecheck/should_compile/T9497a.stderr
parent063e0b4e5ea53a02713eb48555bbd99d934a3de5 (diff)
downloadhaskell-1c9208323b5ccd6796d00763ccba9d3b4a612358.tar.gz
Also show types that subsume a hole as valid substitutions for that hole.
This builds on the previous "Valid substitutions include..." functionality, but add subsumption checking as well, so that the suggested valid substitutions show not only exact matches, but also identifiers that fit the hole by virtue of subsuming the type of the hole (i.e. being more general than the type of the hole). Building on the previous example, in the given program ``` ps :: String -> IO () ps = putStrLn ps2 :: a -> IO () ps2 _ = putStrLn "hello, world" main :: IO () main = _ "hello, world" ``` The results would be something like ``` • Found hole: _ :: [Char] -> IO () • In the expression: _ In the expression: _ "hello, world" In an equation for ‘main’: main = _ "hello, world" • Relevant bindings include main :: IO () (bound at t1.hs:8:1) Valid substitutions include ps :: String -> IO () (defined at t1.hs:2:1) ps2 :: forall a. a -> IO () (defined at t1.hs:5:1) putStrLn :: String -> IO () (imported from ‘Prelude’ at t1.hs:1:1 (and originally defined in ‘System.IO’)) fail :: forall (m :: * -> *). Monad m => forall a. String -> m a (imported from ‘Prelude’ at t1.hs:1:1 (and originally defined in ‘GHC.Base’)) mempty :: forall a. Monoid a => a (imported from ‘Prelude’ at t1.hs:1:1 (and originally defined in ‘GHC.Base’)) print :: forall a. Show a => a -> IO () (imported from ‘Prelude’ at t1.hs:1:1 (and originally defined in ‘System.IO’)) (Some substitutions suppressed; use -fmax-valid-substitutions=N or -fno-max-valid-substitutions) ``` Signed-off-by: Matthías Páll Gissurarson <mpg@mpg.is> Modified according to suggestions from Simon PJ Accept tests that match the expectations, still a few to look better at Swithced to using tcLookup, after sit down with SPJ at ICFP. Implications are WIP. Now works with polymorphism and constraints! We still need to merge the latest master, before we can make a patch. Wrap the type of the hole, instead of implication shenanigans, As per SPJs suggestion, this is simpler and feels closer to what we actually want to do. Updated tests with the new implementation Remove debugging trace and update documentation Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: RyanGlScott, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3930
Diffstat (limited to 'testsuite/tests/typecheck/should_compile/T9497a.stderr')
-rw-r--r--testsuite/tests/typecheck/should_compile/T9497a.stderr12
1 files changed, 12 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T9497a.stderr b/testsuite/tests/typecheck/should_compile/T9497a.stderr
index ddbb5b93f6..413aad24b6 100644
--- a/testsuite/tests/typecheck/should_compile/T9497a.stderr
+++ b/testsuite/tests/typecheck/should_compile/T9497a.stderr
@@ -5,3 +5,15 @@ T9497a.hs:2:8: warning: [-Wtyped-holes (in -Wdefault)]
• In the expression: _main
In an equation for ‘main’: main = _main
• Relevant bindings include main :: IO () (bound at T9497a.hs:2:1)
+ Valid substitutions include
+ mempty :: forall a. Monoid a => a
+ (imported from ‘Prelude’ at T9497a.hs:1:1
+ (and originally defined in ‘GHC.Base’))
+ readLn :: forall a. Read a => IO a
+ (imported from ‘Prelude’ at T9497a.hs:1:1
+ (and originally defined in ‘System.IO’))
+ undefined :: forall (a :: TYPE r).
+ GHC.Stack.Types.HasCallStack =>
+ a
+ (imported from ‘Prelude’ at T9497a.hs:1:1
+ (and originally defined in ‘GHC.Err’))