summaryrefslogtreecommitdiff
path: root/compiler/typecheck/TcSimplify.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2016-04-21 13:03:29 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2016-04-22 11:32:24 +0100
commitedf54d72b5b8a6dd0deafa036dc16dcfc3fcb29f (patch)
tree08d2816f8f3bd349bdea89eeadb655cfda80c26b /compiler/typecheck/TcSimplify.hs
parentf02af79e71f0383cf16b9d7c89691578ab77fa1c (diff)
downloadhaskell-edf54d72b5b8a6dd0deafa036dc16dcfc3fcb29f.tar.gz
Do not use defaulting in ambiguity check
This fixes Trac #11947. See TcSimplify Note [No defaulting in the ambiguity check]
Diffstat (limited to 'compiler/typecheck/TcSimplify.hs')
-rw-r--r--compiler/typecheck/TcSimplify.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/typecheck/TcSimplify.hs b/compiler/typecheck/TcSimplify.hs
index 1f7c984902..8cd7bf4ccc 100644
--- a/compiler/typecheck/TcSimplify.hs
+++ b/compiler/typecheck/TcSimplify.hs
@@ -384,13 +384,25 @@ How is this implemented? It's complicated! So we'll step through it all:
7) `HscMain.tcRnModule'` -- Reads `tcg_safeInfer` after type-checking, calling
`HscMain.markUnsafeInfer` (passing the reason along) when safe-inferrence
failed.
+
+Note [No defaulting in the ambiguity check]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+When simplifying constraints for the ambiguity check, we use
+solveWantedsAndDrop, not simpl_top, so that we do no defaulting.
+Trac #11947 was an example:
+ f :: Num a => Int -> Int
+This is ambiguous of course, but we don't want to default the
+(Num alpha) constraint to (Num Int)! Doing so gives a defaulting
+warning, but no error.
-}
------------------
simplifyAmbiguityCheck :: Type -> WantedConstraints -> TcM ()
simplifyAmbiguityCheck ty wanteds
= do { traceTc "simplifyAmbiguityCheck {" (text "type = " <+> ppr ty $$ text "wanted = " <+> ppr wanteds)
- ; (final_wc, _) <- runTcS $ simpl_top wanteds
+ ; (final_wc, _) <- runTcS $ solveWantedsAndDrop wanteds
+ -- NB: no defaulting! See Note [No defaulting in the ambiguity check]
+
; traceTc "End simplifyAmbiguityCheck }" empty
-- Normally report all errors; but with -XAllowAmbiguousTypes