diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2016-06-11 23:49:27 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2016-06-13 10:57:03 +0100 |
commit | 15b9bf4ba4ab47e6809bf2b3b36ec16e502aea72 (patch) | |
tree | e2e7336c63e9b7130ba70f3551ff290d4a25184b /testsuite/tests/ghci/scripts/Defer02.stderr | |
parent | d25cb61a1c2a135a2564143a332f8b2962f134bc (diff) | |
download | haskell-15b9bf4ba4ab47e6809bf2b3b36ec16e502aea72.tar.gz |
Improve typechecking of let-bindings
This major commit was initially triggered by #11339, but it spiraled
into a major review of the way in which type signatures for bindings
are handled, especially partial type signatures. On the way I fixed a
number of other bugs, namely
#12069
#12033
#11700
#11339
#11670
The main change is that I completely reorganised the way in which type
signatures in bindings are handled. The new story is in TcSigs
Note [Overview of type signatures]. Some specific:
* Changes in the data types for signatures in TcRnTypes:
TcIdSigInfo and new TcIdSigInst
* New module TcSigs deals with typechecking type signatures
and pragmas. It contains code mostly moved from TcBinds,
which is already too big
* HsTypes: I swapped the nesting of HsWildCardBndrs
and HsImplicitBndsrs, so that the wildcards are on the
oustide not the insidde in a LHsSigWcType. This is just
a matter of convenient, nothing deep.
There are a host of other changes as knock-on effects, and
it all took FAR longer than I anticipated :-). But it is
a significant improvement, I think.
Lots of error messages changed slightly, some just variants but
some modest improvements.
New tests
* typecheck/should_compile
* SigTyVars: a scoped-tyvar test
* ExPat, ExPatFail: existential pattern bindings
* T12069
* T11700
* T11339
* partial-sigs/should_compile
* T12033
* T11339a
* T11670
One thing to check:
* Small change to output from ghc-api/landmines.
Need to check with Alan Zimmerman
Diffstat (limited to 'testsuite/tests/ghci/scripts/Defer02.stderr')
-rw-r--r-- | testsuite/tests/ghci/scripts/Defer02.stderr | 395 |
1 files changed, 197 insertions, 198 deletions
diff --git a/testsuite/tests/ghci/scripts/Defer02.stderr b/testsuite/tests/ghci/scripts/Defer02.stderr index 7318eb632a..bcc6c5eff5 100644 --- a/testsuite/tests/ghci/scripts/Defer02.stderr +++ b/testsuite/tests/ghci/scripts/Defer02.stderr @@ -1,198 +1,197 @@ - -../../typecheck/should_run/Defer01.hs:11:40: warning: [-Wdeferred-type-errors (in -Wdefault)] - • Couldn't match type ‘Char’ with ‘[Char]’ - Expected type: String - Actual type: Char - • In the first argument of ‘putStr’, namely ‘','’ - In the second argument of ‘(>>)’, namely ‘putStr ','’ - In the expression: putStr "Hello World" >> putStr ',' - -../../typecheck/should_run/Defer01.hs:14:5: warning: [-Wdeferred-type-errors (in -Wdefault)] - • Couldn't match expected type ‘Int’ with actual type ‘Char’ - • In the expression: 'p' - In an equation for ‘a’: a = 'p' - -../../typecheck/should_run/Defer01.hs:18:7: warning: [-Wdeferred-type-errors (in -Wdefault)] - • No instance for (Eq B) arising from a use of ‘==’ - • In the expression: x == x - In an equation for ‘b’: b x = x == x - -../../typecheck/should_run/Defer01.hs:25:1: warning: [-Woverlapping-patterns (in -Wdefault)] - Pattern match has inaccessible right hand side - In an equation for ‘c’: c (C2 x) = ... - -../../typecheck/should_run/Defer01.hs:25:4: warning: [-Wdeferred-type-errors (in -Wdefault)] - • Couldn't match type ‘Int’ with ‘Bool’ - Inaccessible code in - a pattern with constructor: C2 :: Bool -> C Bool, - in an equation for ‘c’ - • In the pattern: C2 x - In an equation for ‘c’: c (C2 x) = True - -../../typecheck/should_run/Defer01.hs:28:5: warning: [-Wdeferred-type-errors (in -Wdefault)] - • No instance for (Num (a -> a)) arising from the literal ‘1’ - (maybe you haven't applied a function to enough arguments?) - • In the expression: 1 - In an equation for ‘d’: d = 1 - -../../typecheck/should_run/Defer01.hs:31:5: warning: [-Wdeferred-type-errors (in -Wdefault)] - • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’ - • The function ‘e’ is applied to one argument, - but its type ‘Char’ has none - In the expression: e 'q' - In an equation for ‘f’: f = e 'q' - • Relevant bindings include - f :: t (bound at ../../typecheck/should_run/Defer01.hs:31:1) - -../../typecheck/should_run/Defer01.hs:34:8: warning: [-Wdeferred-type-errors (in -Wdefault)] - • Couldn't match expected type ‘Char’ with actual type ‘a’ - ‘a’ is a rigid type variable bound by - the type signature for: - h :: forall a. a -> (Char, Char) - at ../../typecheck/should_run/Defer01.hs:33:6 - • In the expression: x - In the expression: (x, 'c') - In an equation for ‘h’: h x = (x, 'c') - • Relevant bindings include - x :: a (bound at ../../typecheck/should_run/Defer01.hs:34:3) - h :: a -> (Char, Char) - (bound at ../../typecheck/should_run/Defer01.hs:34:1) - -../../typecheck/should_run/Defer01.hs:39:17: warning: [-Wdeferred-type-errors (in -Wdefault)] - • Couldn't match expected type ‘Bool’ with actual type ‘T a’ - • In the first argument of ‘not’, namely ‘(K a)’ - In the expression: (not (K a)) - In the expression: seq (not (K a)) () - • Relevant bindings include - a :: a (bound at ../../typecheck/should_run/Defer01.hs:39:3) - i :: a -> () (bound at ../../typecheck/should_run/Defer01.hs:39:1) - -../../typecheck/should_run/Defer01.hs:43:5: warning: [-Wdeferred-type-errors (in -Wdefault)] - • No instance for (MyClass a1) arising from a use of ‘myOp’ - • In the expression: myOp 23 - In an equation for ‘j’: j = myOp 23 - -../../typecheck/should_run/Defer01.hs:43:10: warning: [-Wdeferred-type-errors (in -Wdefault)] - • Ambiguous type variable ‘a1’ arising from the literal ‘23’ - prevents the constraint ‘(Num a1)’ from being solved. - Probable fix: use a type annotation to specify what ‘a1’ should be. - These potential instances exist: - instance Num Integer -- Defined in ‘GHC.Num’ - instance Num Double -- Defined in ‘GHC.Float’ - instance Num Float -- Defined in ‘GHC.Float’ - ...plus two others - (use -fprint-potential-instances to see them all) - • In the first argument of ‘myOp’, namely ‘23’ - In the expression: myOp 23 - In an equation for ‘j’: j = myOp 23 - -../../typecheck/should_run/Defer01.hs:45:1: warning: [-Wdeferred-type-errors (in -Wdefault)] - Couldn't match type ‘Int’ with ‘Bool’ - Inaccessible code in - the type signature for: - k :: Int ~ Bool => Int -> Bool - -../../typecheck/should_run/Defer01.hs:45:6: warning: [-Wdeferred-type-errors (in -Wdefault)] - • Couldn't match type ‘Int’ with ‘Bool’ - Inaccessible code in - the type signature for: - k :: Int ~ Bool => Int -> Bool - • In the ambiguity check for ‘k’ - To defer the ambiguity check to use sites, enable AllowAmbiguousTypes - In the type signature: - k :: (Int ~ Bool) => Int -> Bool - -../../typecheck/should_run/Defer01.hs:46:1: warning: [-Woverlapping-patterns (in -Wdefault)] - Pattern match is redundant - In an equation for ‘k’: k x = ... - -../../typecheck/should_run/Defer01.hs:49:5: warning: [-Wdeferred-type-errors (in -Wdefault)] - • Couldn't match expected type ‘IO a0’ - with actual type ‘Char -> IO ()’ - • Probable cause: ‘putChar’ is applied to too few arguments - In the first argument of ‘(>>)’, namely ‘putChar’ - In the expression: putChar >> putChar 'p' - In an equation for ‘l’: l = putChar >> putChar 'p' -*** Exception: ../../typecheck/should_run/Defer01.hs:11:40: error: - • Couldn't match type ‘Char’ with ‘[Char]’ - Expected type: String - Actual type: Char - • In the first argument of ‘putStr’, namely ‘','’ - In the second argument of ‘(>>)’, namely ‘putStr ','’ - In the expression: putStr "Hello World" >> putStr ',' -(deferred type error) -*** Exception: ../../typecheck/should_run/Defer01.hs:14:5: error: - • Couldn't match expected type ‘Int’ with actual type ‘Char’ - • In the expression: 'p' - In an equation for ‘a’: a = 'p' -(deferred type error) -*** Exception: ../../typecheck/should_run/Defer01.hs:18:7: error: - • No instance for (Eq B) arising from a use of ‘==’ - • In the expression: x == x - In an equation for ‘b’: b x = x == x -(deferred type error) - -<interactive>:7:11: error: - • Couldn't match type ‘Bool’ with ‘Int’ - Expected type: C Int - Actual type: C Bool - • In the first argument of ‘c’, namely ‘(C2 True)’ - In the first argument of ‘print’, namely ‘(c (C2 True))’ - In the expression: print (c (C2 True)) -*** Exception: ../../typecheck/should_run/Defer01.hs:28:5: error: - • No instance for (Num (a -> a)) arising from the literal ‘1’ - (maybe you haven't applied a function to enough arguments?) - • In the expression: 1 - In an equation for ‘d’: d = 1 -(deferred type error) -*** Exception: ../../typecheck/should_run/Defer01.hs:31:5: error: - • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’ - • The function ‘e’ is applied to one argument, - but its type ‘Char’ has none - In the expression: e 'q' - In an equation for ‘f’: f = e 'q' - • Relevant bindings include - f :: t (bound at ../../typecheck/should_run/Defer01.hs:31:1) -(deferred type error) -*** Exception: ../../typecheck/should_run/Defer01.hs:34:8: error: - • Couldn't match expected type ‘Char’ with actual type ‘a’ - ‘a’ is a rigid type variable bound by - the type signature for: - h :: forall a. a -> (Char, Char) - at ../../typecheck/should_run/Defer01.hs:33:6 - • In the expression: x - In the expression: (x, 'c') - In an equation for ‘h’: h x = (x, 'c') - • Relevant bindings include - x :: a (bound at ../../typecheck/should_run/Defer01.hs:34:3) - h :: a -> (Char, Char) - (bound at ../../typecheck/should_run/Defer01.hs:34:1) -(deferred type error) -*** Exception: ../../typecheck/should_run/Defer01.hs:39:17: error: - • Couldn't match expected type ‘Bool’ with actual type ‘T a’ - • In the first argument of ‘not’, namely ‘(K a)’ - In the expression: (not (K a)) - In the expression: seq (not (K a)) () - • Relevant bindings include - a :: a (bound at ../../typecheck/should_run/Defer01.hs:39:3) - i :: a -> () (bound at ../../typecheck/should_run/Defer01.hs:39:1) -(deferred type error) -*** Exception: ../../typecheck/should_run/Defer01.hs:43:5: error: - • No instance for (MyClass a1) arising from a use of ‘myOp’ - • In the expression: myOp 23 - In an equation for ‘j’: j = myOp 23 -(deferred type error) - -<interactive>:13:8: error: - • Couldn't match type ‘Int’ with ‘Bool’ arising from a use of ‘k’ - • In the first argument of ‘print’, namely ‘(k 2)’ - In the expression: print (k 2) - In an equation for ‘it’: it = print (k 2) -*** Exception: ../../typecheck/should_run/Defer01.hs:49:5: error: - • Couldn't match expected type ‘IO a0’ - with actual type ‘Char -> IO ()’ - • Probable cause: ‘putChar’ is applied to too few arguments - In the first argument of ‘(>>)’, namely ‘putChar’ - In the expression: putChar >> putChar 'p' - In an equation for ‘l’: l = putChar >> putChar 'p' -(deferred type error) +
+..\..\typecheck\should_run\Defer01.hs:11:40: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match type ‘Char’ with ‘[Char]’
+ Expected type: String
+ Actual type: Char
+ • In the first argument of ‘putStr’, namely ‘','’
+ In the second argument of ‘(>>)’, namely ‘putStr ','’
+ In the expression: putStr "Hello World" >> putStr ','
+
+..\..\typecheck\should_run\Defer01.hs:14:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match expected type ‘Int’ with actual type ‘Char’
+ • In the expression: 'p'
+ In an equation for ‘a’: a = 'p'
+
+..\..\typecheck\should_run\Defer01.hs:18:7: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • No instance for (Eq B) arising from a use of ‘==’
+ • In the expression: x == x
+ In an equation for ‘b’: b x = x == x
+
+..\..\typecheck\should_run\Defer01.hs:25:1: warning: [-Woverlapping-patterns (in -Wdefault)]
+ Pattern match has inaccessible right hand side
+ In an equation for ‘c’: c (C2 x) = ...
+
+..\..\typecheck\should_run\Defer01.hs:25:4: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match type ‘Int’ with ‘Bool’
+ Inaccessible code in
+ a pattern with constructor: C2 :: Bool -> C Bool,
+ in an equation for ‘c’
+ • In the pattern: C2 x
+ In an equation for ‘c’: c (C2 x) = True
+
+..\..\typecheck\should_run\Defer01.hs:28:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • No instance for (Num (a -> a)) arising from the literal ‘1’
+ (maybe you haven't applied a function to enough arguments?)
+ • In the expression: 1
+ In an equation for ‘d’: d = 1
+
+..\..\typecheck\should_run\Defer01.hs:31:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’
+ • The function ‘e’ is applied to one argument,
+ but its type ‘Char’ has none
+ In the expression: e 'q'
+ In an equation for ‘f’: f = e 'q'
+ • Relevant bindings include
+ f :: t (bound at ..\..\typecheck\should_run\Defer01.hs:31:1)
+
+..\..\typecheck\should_run\Defer01.hs:34:8: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match expected type ‘Char’ with actual type ‘a’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ h :: forall a. a -> (Char, Char)
+ at ..\..\typecheck\should_run\Defer01.hs:33:1-21
+ • In the expression: x
+ In the expression: (x, 'c')
+ In an equation for ‘h’: h x = (x, 'c')
+ • Relevant bindings include
+ x :: a (bound at ..\..\typecheck\should_run\Defer01.hs:34:3)
+ h :: a -> (Char, Char)
+ (bound at ..\..\typecheck\should_run\Defer01.hs:34:1)
+
+..\..\typecheck\should_run\Defer01.hs:39:17: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match expected type ‘Bool’ with actual type ‘T a’
+ • In the first argument of ‘not’, namely ‘(K a)’
+ In the expression: (not (K a))
+ In the expression: seq (not (K a)) ()
+ • Relevant bindings include
+ a :: a (bound at ..\..\typecheck\should_run\Defer01.hs:39:3)
+ i :: a -> () (bound at ..\..\typecheck\should_run\Defer01.hs:39:1)
+
+..\..\typecheck\should_run\Defer01.hs:43:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • No instance for (MyClass a1) arising from a use of ‘myOp’
+ • In the expression: myOp 23
+ In an equation for ‘j’: j = myOp 23
+
+..\..\typecheck\should_run\Defer01.hs:43:10: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Ambiguous type variable ‘a1’ arising from the literal ‘23’
+ prevents the constraint ‘(Num a1)’ from being solved.
+ Probable fix: use a type annotation to specify what ‘a1’ should be.
+ These potential instances exist:
+ instance Num Integer -- Defined in ‘GHC.Num’
+ instance Num Double -- Defined in ‘GHC.Float’
+ instance Num Float -- Defined in ‘GHC.Float’
+ ...plus two others
+ (use -fprint-potential-instances to see them all)
+ • In the first argument of ‘myOp’, namely ‘23’
+ In the expression: myOp 23
+ In an equation for ‘j’: j = myOp 23
+
+..\..\typecheck\should_run\Defer01.hs:45:1: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ Couldn't match type ‘Int’ with ‘Bool’
+ Inaccessible code in
+ the type signature for:
+ k :: Int ~ Bool => Int -> Bool
+
+..\..\typecheck\should_run\Defer01.hs:45:6: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match type ‘Int’ with ‘Bool’
+ Inaccessible code in
+ the type signature for:
+ k :: Int ~ Bool => Int -> Bool
+ • In the ambiguity check for ‘k’
+ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
+ In the type signature: k :: (Int ~ Bool) => Int -> Bool
+
+..\..\typecheck\should_run\Defer01.hs:46:1: warning: [-Woverlapping-patterns (in -Wdefault)]
+ Pattern match is redundant
+ In an equation for ‘k’: k x = ...
+
+..\..\typecheck\should_run\Defer01.hs:49:5: warning: [-Wdeferred-type-errors (in -Wdefault)]
+ • Couldn't match expected type ‘IO a0’
+ with actual type ‘Char -> IO ()’
+ • Probable cause: ‘putChar’ is applied to too few arguments
+ In the first argument of ‘(>>)’, namely ‘putChar’
+ In the expression: putChar >> putChar 'p'
+ In an equation for ‘l’: l = putChar >> putChar 'p'
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:11:40: error:
+ • Couldn't match type ‘Char’ with ‘[Char]’
+ Expected type: String
+ Actual type: Char
+ • In the first argument of ‘putStr’, namely ‘','’
+ In the second argument of ‘(>>)’, namely ‘putStr ','’
+ In the expression: putStr "Hello World" >> putStr ','
+(deferred type error)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:14:5: error:
+ • Couldn't match expected type ‘Int’ with actual type ‘Char’
+ • In the expression: 'p'
+ In an equation for ‘a’: a = 'p'
+(deferred type error)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:18:7: error:
+ • No instance for (Eq B) arising from a use of ‘==’
+ • In the expression: x == x
+ In an equation for ‘b’: b x = x == x
+(deferred type error)
+
+<interactive>:7:11: error:
+ • Couldn't match type ‘Bool’ with ‘Int’
+ Expected type: C Int
+ Actual type: C Bool
+ • In the first argument of ‘c’, namely ‘(C2 True)’
+ In the first argument of ‘print’, namely ‘(c (C2 True))’
+ In the expression: print (c (C2 True))
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:28:5: error:
+ • No instance for (Num (a -> a)) arising from the literal ‘1’
+ (maybe you haven't applied a function to enough arguments?)
+ • In the expression: 1
+ In an equation for ‘d’: d = 1
+(deferred type error)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:31:5: error:
+ • Couldn't match expected type ‘Char -> t’ with actual type ‘Char’
+ • The function ‘e’ is applied to one argument,
+ but its type ‘Char’ has none
+ In the expression: e 'q'
+ In an equation for ‘f’: f = e 'q'
+ • Relevant bindings include
+ f :: t (bound at ..\..\typecheck\should_run\Defer01.hs:31:1)
+(deferred type error)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:34:8: error:
+ • Couldn't match expected type ‘Char’ with actual type ‘a’
+ ‘a’ is a rigid type variable bound by
+ the type signature for:
+ h :: forall a. a -> (Char, Char)
+ at ..\..\typecheck\should_run\Defer01.hs:33:1-21
+ • In the expression: x
+ In the expression: (x, 'c')
+ In an equation for ‘h’: h x = (x, 'c')
+ • Relevant bindings include
+ x :: a (bound at ..\..\typecheck\should_run\Defer01.hs:34:3)
+ h :: a -> (Char, Char)
+ (bound at ..\..\typecheck\should_run\Defer01.hs:34:1)
+(deferred type error)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:39:17: error:
+ • Couldn't match expected type ‘Bool’ with actual type ‘T a’
+ • In the first argument of ‘not’, namely ‘(K a)’
+ In the expression: (not (K a))
+ In the expression: seq (not (K a)) ()
+ • Relevant bindings include
+ a :: a (bound at ..\..\typecheck\should_run\Defer01.hs:39:3)
+ i :: a -> () (bound at ..\..\typecheck\should_run\Defer01.hs:39:1)
+(deferred type error)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:43:5: error:
+ • No instance for (MyClass a1) arising from a use of ‘myOp’
+ • In the expression: myOp 23
+ In an equation for ‘j’: j = myOp 23
+(deferred type error)
+
+<interactive>:13:8: error:
+ • Couldn't match type ‘Int’ with ‘Bool’ arising from a use of ‘k’
+ • In the first argument of ‘print’, namely ‘(k 2)’
+ In the expression: print (k 2)
+ In an equation for ‘it’: it = print (k 2)
+*** Exception: ..\..\typecheck\should_run\Defer01.hs:49:5: error:
+ • Couldn't match expected type ‘IO a0’
+ with actual type ‘Char -> IO ()’
+ • Probable cause: ‘putChar’ is applied to too few arguments
+ In the first argument of ‘(>>)’, namely ‘putChar’
+ In the expression: putChar >> putChar 'p'
+ In an equation for ‘l’: l = putChar >> putChar 'p'
+(deferred type error)
|