Commit 6282bc31 authored by niteria's avatar niteria
Browse files

Kill varSetElems in tidyFreeTyCoVars

I haven't observed this to have an effect on nondeterminism,
but tidyOccName appears to modify the TidyOccEnv in a
way dependent on the order of inputs.
It's easy enough to change it to be deterministic to be on the
safe side.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2238

GHC Trac Issues: #4012
parent f18e8d8d
......@@ -175,10 +175,10 @@ report_unsolved mb_binds_var err_as_warn type_errors expr_holes type_holes wante
-- If we are deferring we are going to need /all/ evidence around,
-- including the evidence produced by unflattening (zonkWC)
; let tidy_env = tidyFreeTyCoVars env0 free_tvs
free_tvs = tyCoVarsOfWC wanted
free_tvs = tyCoVarsOfWCList wanted
; traceTc "reportUnsolved (after zonking and tidying):" $
vcat [ pprVarSet free_tvs pprTvBndrs
vcat [ pprTvBndrs free_tvs
, ppr wanted ]
; warn_redundant <- woptM Opt_WarnRedundantConstraints
......@@ -2631,7 +2631,7 @@ warnDefaulting wanteds default_ty
= do { warn_default <- woptM Opt_WarnTypeDefaults
; env0 <- tcInitTidyEnv
; let tidy_env = tidyFreeTyCoVars env0 $
foldr (unionVarSet . tyCoVarsOfCt) emptyVarSet wanteds
tyCoVarsOfCtsList (listToBag wanteds)
tidy_wanteds = map (tidyCt tidy_env) wanteds
(loc, ppr_wanteds) = pprWithArising tidy_wanteds
warn_msg =
......@@ -2663,7 +2663,7 @@ solverDepthErrorTcS loc ty
= setCtLocM loc $
do { ty <- zonkTcType ty
; env0 <- tcInitTidyEnv
; let tidy_env = tidyFreeTyCoVars env0 (tyCoVarsOfType ty)
; let tidy_env = tidyFreeTyCoVars env0 (tyCoVarsOfTypeList ty)
tidy_ty = tidyType tidy_env ty
msg
= vcat [ text "Reduction stack overflow; size =" <+> ppr depth
......
......@@ -1148,7 +1148,7 @@ tcInitTidyEnv
-- | Get a 'TidyEnv' that includes mappings for all vars free in the given
-- type. Useful when tidying open types.
tcInitOpenTidyEnv :: TyCoVarSet -> TcM TidyEnv
tcInitOpenTidyEnv :: [TyCoVar] -> TcM TidyEnv
tcInitOpenTidyEnv tvs
= do { env1 <- tcInitTidyEnv
; let env2 = tidyFreeTyCoVars env1 tvs
......
......@@ -349,7 +349,7 @@ checkValidType ctxt ty
_ -> panic "checkValidType"
-- Can't happen; not used for *user* sigs
; env <- tcInitOpenTidyEnv (tyCoVarsOfType ty)
; env <- tcInitOpenTidyEnv (tyCoVarsOfTypeList ty)
-- Check the internal validity of the type itself
; check_type env ctxt rank ty
......@@ -371,7 +371,7 @@ checkValidType ctxt ty
checkValidMonoType :: Type -> TcM ()
-- Assumes arguemt is fully zonked
checkValidMonoType ty
= do { env <- tcInitOpenTidyEnv (tyCoVarsOfType ty)
= do { env <- tcInitOpenTidyEnv (tyCoVarsOfTypeList ty)
; check_type env SigmaCtxt MustBeMonoType ty }
check_kind :: TidyEnv -> UserTypeCtxt -> TcType -> TcM ()
......@@ -471,7 +471,7 @@ kind system should check for uses of unlifted types. So I've
removed the check. See Trac #11120 comment:19.
check_lifted ty
= do { env <- tcInitOpenTidyEnv (tyCoVarsOfType ty)
= do { env <- tcInitOpenTidyEnv (tyCoVarsOfTypeList ty)
; checkTcM (not (isUnliftedType ty)) (unliftedArgErr env ty) }
unliftedArgErr :: TidyEnv -> Type -> (TidyEnv, SDoc)
......@@ -707,7 +707,7 @@ applying the instance decl would show up two uses of ?x. Trac #8912.
checkValidTheta :: UserTypeCtxt -> ThetaType -> TcM ()
-- Assumes arguemt is fully zonked
checkValidTheta ctxt theta
= do { env <- tcInitOpenTidyEnv (tyCoVarsOfTypes theta)
= do { env <- tcInitOpenTidyEnv (tyCoVarsOfTypesList theta)
; addErrCtxtM (checkThetaCtxt ctxt theta) $
check_valid_theta env ctxt theta }
......
......@@ -3155,11 +3155,11 @@ tidyTyBinders :: TidyEnv -> [TyBinder] -> (TidyEnv, [TyBinder])
tidyTyBinders = mapAccumL tidyTyBinder
---------------
tidyFreeTyCoVars :: TidyEnv -> TyCoVarSet -> TidyEnv
tidyFreeTyCoVars :: TidyEnv -> [TyCoVar] -> TidyEnv
-- ^ Add the free 'TyVar's to the env in tidy form,
-- so that we can tidy the type they are free in
tidyFreeTyCoVars (full_occ_env, var_env) tyvars
= fst (tidyOpenTyCoVars (full_occ_env, var_env) (varSetElems tyvars))
= fst (tidyOpenTyCoVars (full_occ_env, var_env) tyvars)
---------------
tidyOpenTyCoVars :: TidyEnv -> [TyCoVar] -> (TidyEnv, [TyCoVar])
......@@ -3174,8 +3174,8 @@ tidyOpenTyCoVar env@(_, subst) tyvar
= case lookupVarEnv subst tyvar of
Just tyvar' -> (env, tyvar') -- Already substituted
Nothing ->
let env' = tidyFreeTyCoVars env (tyCoVarsOfType (tyVarKind tyvar)) in
tidyTyCoVarBndr env' tyvar -- Treat it as a binder
let env' = tidyFreeTyCoVars env (tyCoVarsOfTypeList (tyVarKind tyvar))
in tidyTyCoVarBndr env' tyvar -- Treat it as a binder
---------------
tidyTyVarOcc :: TidyEnv -> TyVar -> TyVar
......
......@@ -24,8 +24,8 @@ T2693.hs:19:15: error:
• Relevant bindings include n :: a5 (bound at T2693.hs:19:7)
T2693.hs:19:23: error:
• Couldn't match expected type ‘(a3, a5)’ with actual type ‘TFn a4
The type variables ‘a4’, ‘a3’, ‘a5’ are ambiguous
• Couldn't match expected type ‘(a4, a5)’ with actual type ‘TFn a3
The type variables ‘a3’, ‘a4’, ‘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
......
overloadedlabelsfail01.hs:6:5: error:
No instance for (IsLabel "x" t2)
arising from the overloaded label ‘#x’
In the expression: #x
In an equation for ‘a’: a = #x
No instance for (IsLabel "x" t2)
arising from the overloaded label ‘#x’
In the expression: #x
In an equation for ‘a’: a = #x
overloadedlabelsfail01.hs:9:5: error:
No instance for (IsLabel "x" (t0 -> t1))
arising from the overloaded label ‘#x’
(maybe you haven't applied a function to enough arguments?)
In the expression: #x
In the expression: #x #y
In an equation for ‘b’: b = #x #y
No instance for (IsLabel "x" (t1 -> t0))
arising from the overloaded label ‘#x’
(maybe you haven't applied a function to enough arguments?)
In the expression: #x
In the expression: #x #y
In an equation for ‘b’: b = #x #y
overloadedlabelsfail01.hs:9:8: error:
No instance for (IsLabel "y" t0)
arising from the overloaded label ‘#y’
In the first argument of ‘#x’, namely ‘#y’
In the expression: #x #y
In an equation for ‘b’: b = #x #y
No instance for (IsLabel "y" t1)
arising from the overloaded label ‘#y’
In the first argument of ‘#x’, namely ‘#y’
In the expression: #x #y
In an equation for ‘b’: b = #x #y
overloadedlabelsfail01.hs:13:5: error:
Could not deduce (IsLabel "y" t)
arising from the overloaded label ‘#y’
from the context: IsLabel "x" t
bound by the type signature for:
c :: IsLabel "x" t => t
at overloadedlabelsfail01.hs:12:1-23
In the expression: #y
In an equation for ‘c’: c = #y
Could not deduce (IsLabel "y" t)
arising from the overloaded label ‘#y’
from the context: IsLabel "x" t
bound by the type signature for:
c :: IsLabel "x" t => t
at overloadedlabelsfail01.hs:12:1-23
In the expression: #y
In an equation for ‘c’: c = #y
T7848.hs:6:1: error:
• Occurs check: cannot construct the infinite type:
t ~ t0 -> t1 -> A -> A -> A -> A -> t2 -> t
t ~ t2 -> t1 -> A -> A -> A -> A -> t0 -> t
• When checking that:
t0 -> t1 -> A -> A -> A -> A -> forall t2. t2 -> t
t2 -> t1 -> A -> A -> A -> A -> forall t4. t4 -> t
is more polymorphic than: t
• Relevant bindings include x :: t (bound at T7848.hs:6:1)
......
T10618.hs:3:22: error:
• Variable not in scope: (<>) :: Maybe (Maybe a0) -> Maybe a1 -> t
• Variable not in scope: (<>) :: Maybe (Maybe a1) -> Maybe a0 -> t
• Perhaps you meant one of these:
‘<$>’ (imported from Prelude), ‘*>’ (imported from Prelude),
‘<$’ (imported from Prelude)
T11355.hs:5:7: error:
• Illegal polymorphic type: forall (a :: TYPE t0). a
• Illegal polymorphic type: forall (a :: TYPE t1). a
GHC doesn't yet support impredicative polymorphism
• In the expression:
const @_ @((forall a. a) -> forall a. a) () (id @(forall a. a))
......
T5684.hs:20:12:
No instance for (A Bool) arising from a use of ‘op’
In the expression: op False False
In the expression:
[op False False, op 'c' undefined, op True undefined]
In an equation for ‘flop1’:
flop1 = [op False False, op 'c' undefined, op True undefined]
T5684.hs:24:12:
No instance for (B Char b10) arising from a use of ‘op’
In the expression: op 'c' undefined
In the expression:
[op False False, op 'c' undefined, op True undefined]
In an equation for ‘flop1’:
flop1 = [op False False, op 'c' undefined, op True undefined]
T5684.hs:25:12:
No instance for (A b11) arising from a use of ‘op’
In the expression: op True undefined
In the expression:
[op False False, op 'c' undefined, op True undefined]
In an equation for ‘flop1’:
flop1 = [op False False, op 'c' undefined, op True undefined]
T5684.hs:29:12:
No instance for (A Bool) arising from a use of ‘op’
In the expression: op False False
In the expression:
[op False False, op True undefined, op 'c' undefined]
In an equation for ‘flop2’:
flop2 = [op False False, op True undefined, op 'c' undefined]
T5684.hs:30:12:
No instance for (A b8) arising from a use of ‘op’
In the expression: op True undefined
In the expression:
[op False False, op True undefined, op 'c' undefined]
In an equation for ‘flop2’:
flop2 = [op False False, op True undefined, op 'c' undefined]
T5684.hs:31:12:
No instance for (B Char b9) arising from a use of ‘op’
In the expression: op 'c' undefined
In the expression:
[op False False, op True undefined, op 'c' undefined]
In an equation for ‘flop2’:
flop2 = [op False False, op True undefined, op 'c' undefined]
T5684.hs:35:12:
No instance for (B Char b6) arising from a use of ‘op’
In the expression: op 'c' undefined
In the expression:
[op 'c' undefined, op True undefined, op False False]
In an equation for ‘flop3’:
flop3 = [op 'c' undefined, op True undefined, op False False]
T5684.hs:36:12:
No instance for (A b7) arising from a use of ‘op’
In the expression: op True undefined
In the expression:
[op 'c' undefined, op True undefined, op False False]
In an equation for ‘flop3’:
flop3 = [op 'c' undefined, op True undefined, op False False]
T5684.hs:37:12:
No instance for (A Bool) arising from a use of ‘op’
In the expression: op False False
In the expression:
[op 'c' undefined, op True undefined, op False False]
In an equation for ‘flop3’:
flop3 = [op 'c' undefined, op True undefined, op False False]
T5684.hs:40:12:
No instance for (B Char b4) arising from a use of ‘op’
In the expression: op 'c' undefined
In the expression:
[op 'c' undefined, op False False, op True undefined]
In an equation for ‘flop4’:
flop4 = [op 'c' undefined, op False False, op True undefined]
T5684.hs:41:12:
No instance for (A Bool) arising from a use of ‘op’
In the expression: op False False
In the expression:
[op 'c' undefined, op False False, op True undefined]
In an equation for ‘flop4’:
flop4 = [op 'c' undefined, op False False, op True undefined]
T5684.hs:42:12:
No instance for (A b5) arising from a use of ‘op’
In the expression: op True undefined
In the expression:
[op 'c' undefined, op False False, op True undefined]
In an equation for ‘flop4’:
flop4 = [op 'c' undefined, op False False, op True undefined]
T5684.hs:46:12:
No instance for (A b2) arising from a use of ‘op’
In the expression: op True undefined
In the expression:
[op True undefined, op 'c' undefined, op False False]
In an equation for ‘flop5’:
flop5 = [op True undefined, op 'c' undefined, op False False]
T5684.hs:47:12:
No instance for (B Char b3) arising from a use of ‘op’
In the expression: op 'c' undefined
In the expression:
[op True undefined, op 'c' undefined, op False False]
In an equation for ‘flop5’:
flop5 = [op True undefined, op 'c' undefined, op False False]
T5684.hs:48:12:
No instance for (A Bool) arising from a use of ‘op’
In the expression: op False False
In the expression:
[op True undefined, op 'c' undefined, op False False]
In an equation for ‘flop5’:
flop5 = [op True undefined, op 'c' undefined, op False False]
T5684.hs:52:12:
No instance for (A b0) arising from a use of ‘op’
In the expression: op True undefined
In the expression:
[op True undefined, op False False, op 'c' undefined]
In an equation for ‘flop6’:
flop6 = [op True undefined, op False False, op 'c' undefined]
T5684.hs:53:12:
No instance for (A Bool) arising from a use of ‘op’
In the expression: op False False
In the expression:
[op True undefined, op False False, op 'c' undefined]
In an equation for ‘flop6’:
flop6 = [op True undefined, op False False, op 'c' undefined]
T5684.hs:54:12:
No instance for (B Char b1) arising from a use of ‘op’
In the expression: op 'c' undefined
In the expression:
[op True undefined, op False False, op 'c' undefined]
In an equation for ‘flop6’:
flop6 = [op True undefined, op False False, op 'c' undefined]
T5684.hs:20:12: error:
No instance for (A Bool) arising from a use of ‘op’
In the expression: op False False
In the expression:
[op False False, op 'c' undefined, op True undefined]
In an equation for ‘flop1’:
flop1 = [op False False, op 'c' undefined, op True undefined]
T5684.hs:24:12: error:
No instance for (B Char b10) arising from a use of ‘op’
In the expression: op 'c' undefined
In the expression:
[op False False, op 'c' undefined, op True undefined]
In an equation for ‘flop1’:
flop1 = [op False False, op 'c' undefined, op True undefined]
T5684.hs:25:12: error:
No instance for (A b11) arising from a use of ‘op’
In the expression: op True undefined
In the expression:
[op False False, op 'c' undefined, op True undefined]
In an equation for ‘flop1’:
flop1 = [op False False, op 'c' undefined, op True undefined]
T5684.hs:29:12: error:
No instance for (A Bool) arising from a use of ‘op’
In the expression: op False False
In the expression:
[op False False, op True undefined, op 'c' undefined]
In an equation for ‘flop2’:
flop2 = [op False False, op True undefined, op 'c' undefined]
T5684.hs:30:12: error:
No instance for (A b8) arising from a use of ‘op’
In the expression: op True undefined
In the expression:
[op False False, op True undefined, op 'c' undefined]
In an equation for ‘flop2’:
flop2 = [op False False, op True undefined, op 'c' undefined]
T5684.hs:31:12: error:
No instance for (B Char b9) arising from a use of ‘op’
In the expression: op 'c' undefined
In the expression:
[op False False, op True undefined, op 'c' undefined]
In an equation for ‘flop2’:
flop2 = [op False False, op True undefined, op 'c' undefined]
T5684.hs:35:12: error:
No instance for (B Char b6) arising from a use of ‘op’
In the expression: op 'c' undefined
In the expression:
[op 'c' undefined, op True undefined, op False False]
In an equation for ‘flop3’:
flop3 = [op 'c' undefined, op True undefined, op False False]
T5684.hs:36:12: error:
No instance for (A b7) arising from a use of ‘op’
In the expression: op True undefined
In the expression:
[op 'c' undefined, op True undefined, op False False]
In an equation for ‘flop3’:
flop3 = [op 'c' undefined, op True undefined, op False False]
T5684.hs:37:12: error:
No instance for (A Bool) arising from a use of ‘op’
In the expression: op False False
In the expression:
[op 'c' undefined, op True undefined, op False False]
In an equation for ‘flop3’:
flop3 = [op 'c' undefined, op True undefined, op False False]
T5684.hs:40:12: error:
No instance for (B Char b4) arising from a use of ‘op’
In the expression: op 'c' undefined
In the expression:
[op 'c' undefined, op False False, op True undefined]
In an equation for ‘flop4’:
flop4 = [op 'c' undefined, op False False, op True undefined]
T5684.hs:41:12: error:
No instance for (A Bool) arising from a use of ‘op’
In the expression: op False False
In the expression:
[op 'c' undefined, op False False, op True undefined]
In an equation for ‘flop4’:
flop4 = [op 'c' undefined, op False False, op True undefined]
T5684.hs:42:12: error:
No instance for (A b5) arising from a use of ‘op’
In the expression: op True undefined
In the expression:
[op 'c' undefined, op False False, op True undefined]
In an equation for ‘flop4’:
flop4 = [op 'c' undefined, op False False, op True undefined]
T5684.hs:46:12: error:
No instance for (A b3) arising from a use of ‘op’
In the expression: op True undefined
In the expression:
[op True undefined, op 'c' undefined, op False False]
In an equation for ‘flop5’:
flop5 = [op True undefined, op 'c' undefined, op False False]
T5684.hs:47:12: error:
No instance for (B Char b2) arising from a use of ‘op’
In the expression: op 'c' undefined
In the expression:
[op True undefined, op 'c' undefined, op False False]
In an equation for ‘flop5’:
flop5 = [op True undefined, op 'c' undefined, op False False]
T5684.hs:48:12: error:
No instance for (A Bool) arising from a use of ‘op’
In the expression: op False False
In the expression:
[op True undefined, op 'c' undefined, op False False]
In an equation for ‘flop5’:
flop5 = [op True undefined, op 'c' undefined, op False False]
T5684.hs:52:12: error:
No instance for (A b0) arising from a use of ‘op’
In the expression: op True undefined
In the expression:
[op True undefined, op False False, op 'c' undefined]
In an equation for ‘flop6’:
flop6 = [op True undefined, op False False, op 'c' undefined]
T5684.hs:53:12: error:
No instance for (A Bool) arising from a use of ‘op’
In the expression: op False False
In the expression:
[op True undefined, op False False, op 'c' undefined]
In an equation for ‘flop6’:
flop6 = [op True undefined, op False False, op 'c' undefined]
T5684.hs:54:12: error:
No instance for (B Char b1) arising from a use of ‘op’
In the expression: op 'c' undefined
In the expression:
[op True undefined, op False False, op 'c' undefined]
In an equation for ‘flop6’:
flop6 = [op True undefined, op False False, op 'c' undefined]
T7851.hs:5:10: error:
• Couldn't match expected type ‘IO a0
with actual type ‘a1 -> IO ()’
• Couldn't match expected type ‘IO a1
with actual type ‘a0 -> IO ()’
• Probable cause: ‘print’ is applied to too few arguments
In a stmt of a 'do' block: print
In the expression:
......
tcfail001.hs:9:2: error:
• Couldn't match expected type ‘[a]’
with actual type ‘[t0] -> [t1]’
with actual type ‘[t1] -> [t0]’
• The equation(s) for ‘op’ have one argument,
but its type ‘[a]’ has none
In the instance declaration for ‘A [a]’
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment