[commit: ghc] master: Kill varSetElems in TcErrors (2dc5b92)

git at git.haskell.org git at git.haskell.org
Tue Apr 26 15:45:29 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/2dc5b92e070132114ea1a37f5bd82ab905ff7889/ghc

>---------------------------------------------------------------

commit 2dc5b92e070132114ea1a37f5bd82ab905ff7889
Author: Bartosz Nitka <niteria at gmail.com>
Date:   Tue Apr 26 08:47:21 2016 -0700

    Kill varSetElems in TcErrors
    
    The uses of varSetElems in these places are unnecessary and while it
    doesn't intruduce non-determinism in the ABI the plan is to get
    rid of all varSetElems to get some compile time guarantees.
    
    Test Plan: ./validate
    
    Reviewers: austin, simonmar, bgamari, goldfire, simonpj
    
    Reviewed By: simonpj
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2141
    
    GHC Trac Issues: #4012


>---------------------------------------------------------------

2dc5b92e070132114ea1a37f5bd82ab905ff7889
 compiler/typecheck/TcErrors.hs                     | 14 ++++-----
 .../tests/dependent/should_fail/T11407.stderr      |  2 +-
 .../tests/indexed-types/should_fail/T2693.stderr   |  8 ++---
 testsuite/tests/typecheck/should_fail/T4921.stderr | 34 +++++++++++-----------
 4 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/compiler/typecheck/TcErrors.hs b/compiler/typecheck/TcErrors.hs
index 7d64d7e..f23a75b 100644
--- a/compiler/typecheck/TcErrors.hs
+++ b/compiler/typecheck/TcErrors.hs
@@ -52,6 +52,7 @@ import StaticFlags      ( opt_PprStyle_Debug )
 import ListSetOps       ( equivClasses )
 import Maybes
 import qualified GHC.LanguageExtensions as LangExt
+import FV ( fvVarList, unionFV )
 
 import Control.Monad    ( when )
 import Data.List        ( partition, mapAccumL, nub, sortBy )
@@ -177,7 +178,7 @@ report_unsolved mb_binds_var err_as_warn type_errors expr_holes type_holes wante
              free_tvs = tyCoVarsOfWC wanted
 
        ; traceTc "reportUnsolved (after zonking and tidying):" $
-         vcat [ pprTvBndrs (varSetElems free_tvs)
+         vcat [ pprVarSet pprTvBndrs free_tvs
               , ppr wanted ]
 
        ; warn_redundant <- woptM Opt_WarnRedundantConstraints
@@ -1337,8 +1338,8 @@ mkTyVarEqErr dflags ctxt report ct oriented tv1 ty2
              interesting_tyvars
                = filter (not . isEmptyVarSet . tyCoVarsOfType . tyVarKind) $
                  filter isTyVar $
-                 varSetElems $
-                 tyCoVarsOfType ty1 `unionVarSet` tyCoVarsOfType ty2
+                 fvVarList $
+                 tyCoFVsOfType ty1 `unionFV` tyCoFVsOfType ty2
              extra3 = relevant_bindings $
                       ppWhen (not (null interesting_tyvars)) $
                       hang (text "Type variable kinds:") 2 $
@@ -2457,10 +2458,9 @@ getAmbigTkvs :: Ct -> ([Var],[Var])
 getAmbigTkvs ct
   = partition (`elemVarSet` dep_tkv_set) ambig_tkvs
   where
-    tkv_set       = tyCoVarsOfCt ct
-    ambig_tkv_set = filterVarSet isAmbiguousTyVar tkv_set
-    dep_tkv_set   = tyCoVarsOfTypes (map tyVarKind (varSetElems tkv_set))
-    ambig_tkvs    = varSetElems ambig_tkv_set
+    tkvs       = tyCoVarsOfCtList ct
+    ambig_tkvs = filter isAmbiguousTyVar tkvs
+    dep_tkv_set = tyCoVarsOfTypes (map tyVarKind tkvs)
 
 getSkolemInfo :: [Implication] -> TcTyVar -> ([TcTyVar], SkolemInfo)
 -- Get the skolem info for a type variable
diff --git a/testsuite/tests/dependent/should_fail/T11407.stderr b/testsuite/tests/dependent/should_fail/T11407.stderr
index b5d95bf..b07aa2b 100644
--- a/testsuite/tests/dependent/should_fail/T11407.stderr
+++ b/testsuite/tests/dependent/should_fail/T11407.stderr
@@ -4,5 +4,5 @@ T11407.hs:10:40: error:
     • In the second argument of ‘UhOh’, namely ‘(a :: x a)’
       In the data instance declaration for ‘UhOh’
     • Type variable kinds:
-        a :: k0
         x :: k0 -> *
+        a :: k0
diff --git a/testsuite/tests/indexed-types/should_fail/T2693.stderr b/testsuite/tests/indexed-types/should_fail/T2693.stderr
index 0c00711..a0ac4ea 100644
--- a/testsuite/tests/indexed-types/should_fail/T2693.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T2693.stderr
@@ -1,7 +1,7 @@
 
 T2693.hs:12:15: error:
     • Couldn't match expected type ‘(a8, b1)’ with actual type ‘TFn a6’
-      The type variables ‘b1’, ‘a6’, ‘a8’ are ambiguous
+      The type variables ‘a6’, ‘a8’, ‘b1’ are ambiguous
     • In the first argument of ‘fst’, namely ‘x’
       In the first argument of ‘(+)’, namely ‘fst x’
       In the expression: fst x + fst x
@@ -9,7 +9,7 @@ T2693.hs:12:15: error:
 
 T2693.hs:12:23: error:
     • Couldn't match expected type ‘(a8, b2)’ with actual type ‘TFn a7’
-      The type variables ‘b2’, ‘a7’, ‘a8’ are ambiguous
+      The type variables ‘a7’, ‘a8’, ‘b2’ are ambiguous
     • In the first argument of ‘fst’, namely ‘x’
       In the second argument of ‘(+)’, namely ‘fst x’
       In the expression: fst x + fst x
@@ -17,7 +17,7 @@ T2693.hs:12:23: error:
 
 T2693.hs:19:15: error:
     • Couldn't match expected type ‘(a5, b0)’ with actual type ‘TFn a2’
-      The type variables ‘b0’, ‘a2’, ‘a5’ are ambiguous
+      The type variables ‘a2’, ‘a5’, ‘b0’ are ambiguous
     • In the first argument of ‘fst’, namely ‘x’
       In the first argument of ‘(+)’, namely ‘fst x’
       In the expression: fst x + snd x
@@ -25,7 +25,7 @@ T2693.hs:19:15: error:
 
 T2693.hs:19:23: error:
     • Couldn't match expected type ‘(a3, a5)’ with actual type ‘TFn a4’
-      The type variables ‘a3’, ‘a4’, ‘a5’ are ambiguous
+      The type variables ‘a4’, ‘a3’, ‘a5’ are ambiguous
     • In the first argument of ‘snd’, namely ‘x’
       In the second argument of ‘(+)’, namely ‘snd x’
       In the expression: fst x + snd x
diff --git a/testsuite/tests/typecheck/should_fail/T4921.stderr b/testsuite/tests/typecheck/should_fail/T4921.stderr
index 42d5a8a..8eff919 100644
--- a/testsuite/tests/typecheck/should_fail/T4921.stderr
+++ b/testsuite/tests/typecheck/should_fail/T4921.stderr
@@ -1,21 +1,21 @@
 
 T4921.hs:10:9: error:
-    Ambiguous type variables ‘b1’, ‘a0’ arising from a use of ‘f’
-    prevents the constraint ‘(C a0 b1)’ from being solved.
-    Relevant bindings include x :: a0 (bound at T4921.hs:10:1)
-    Probable fix: use a type annotation to specify what ‘b1’, ‘a0’ should be.
-    These potential instance exist:
-      instance C Int Char -- Defined at T4921.hs:7:10
-    In the first argument of ‘fst’, namely ‘f’
-    In the expression: fst f
-    In an equation for ‘x’: x = fst f
+    • Ambiguous type variables ‘a0’, ‘b1’ arising from a use of ‘f’
+      prevents the constraint ‘(C a0 b1)’ from being solved.
+      Relevant bindings include x :: a0 (bound at T4921.hs:10:1)
+      Probable fix: use a type annotation to specify what ‘a0’, ‘b1’ should be.
+      These potential instance exist:
+        instance C Int Char -- Defined at T4921.hs:7:10
+    • In the first argument of ‘fst’, namely ‘f’
+      In the expression: fst f
+      In an equation for ‘x’: x = fst f
 
 T4921.hs:12:9: error:
-    Ambiguous type variable ‘b0’ arising from a use of ‘f’
-    prevents the constraint ‘(C Int b0)’ from being solved.
-    Probable fix: use a type annotation to specify what ‘b0’ should be.
-    These potential instance exist:
-      instance C Int Char -- Defined at T4921.hs:7:10
-    In the first argument of ‘fst’, namely ‘f’
-    In the expression: fst f :: Int
-    In an equation for ‘y’: y = fst f :: Int
+    • Ambiguous type variable ‘b0’ arising from a use of ‘f’
+      prevents the constraint ‘(C Int b0)’ from being solved.
+      Probable fix: use a type annotation to specify what ‘b0’ should be.
+      These potential instance exist:
+        instance C Int Char -- Defined at T4921.hs:7:10
+    • In the first argument of ‘fst’, namely ‘f’
+      In the expression: fst f :: Int
+      In an equation for ‘y’: y = fst f :: Int



More information about the ghc-commits mailing list