Simon Peyton Jones pushed to branch wip/T27994 at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC/Core/Unify.hs
    ... ... @@ -1166,9 +1166,9 @@ niFixSubst' in_scope orig_tenv
    1166 1166
                    filterOut in_dom  $
    
    1167 1167
                    nonDetVarSetElems $
    
    1168 1168
                    tyCoVarsOfTypes   $
    
    1169
    -               nonDetEltsUFM orig_tenv
    
    1169
    +               nonDetEltsUFM fix_tenv
    
    1170 1170
               -- It's OK to use nonDetEltsUFM (twice) here because
    
    1171
    -          -- the order of range_tvs is immaterial
    
    1171
    +          -- the exact order of free_tvs is immaterial
    
    1172 1172
     
    
    1173 1173
         rekinding_tenv = foldl' add_free_tv emptyTvSubstEnv free_tvs
    
    1174 1174
     
    

  • compiler/GHC/Tc/Solver/FunDeps.hs
    ... ... @@ -735,8 +735,9 @@ mkTopOpenFamEqFDs fam_tc inj_flags work_args (EqCt { eq_rhs = work_rhs })
    735 735
           | Just {} <- tcUnifyTysForInjectivity Matching [branch_rhs] [work_rhs]
    
    736 736
             -- No need for an apartness check here;
    
    737 737
             -- for open type families there are no "preceding" equations
    
    738
    -      = Just (mkInjectivityFDEqn inj_flags branch_qtvs
    
    739
    -                                 (branch_rhs:branch_lhs_tys) (work_rhs:work_args))
    
    738
    +      = Just (mkInjectivityFDEqn branch_qtvs (True:       inj_flags)
    
    739
    +                                             (branch_rhs: branch_lhs_tys)
    
    740
    +                                             (work_rhs:   work_args))
    
    740 741
     
    
    741 742
           | otherwise
    
    742 743
           = Nothing
    
    ... ... @@ -761,7 +762,7 @@ mkLocalFamEqFDs eqs_for_me fam_tc inj_flags work_args work_rhs
    761 762
           | otherwise                     = Nothing
    
    762 763
         do_one _ = pprPanic "interactFunEq 2" (ppr fam_tc)  -- TyVarLHS
    
    763 764
     
    
    764
    -    mk_eqn iargs = mkInjectivityFDEqn inj_flags [] work_args iargs
    
    765
    +    mk_eqn iargs = mkInjectivityFDEqn [] inj_flags work_args iargs
    
    765 766
     
    
    766 767
     
    
    767 768
     {- See Historical Note [trim_qtvs]
    
    ... ... @@ -879,15 +880,22 @@ mkLocalBuiltinFamEqFDs eqs_for_me fam_tc ops work_args work_rhs
    879 880
            ; return (eqns_from_inerts ++ eqns_from_self) }
    
    880 881
     
    
    881 882
     --------------------
    
    882
    -mkInjectivityFDEqn :: [Bool]       -- Injectivity flags
    
    883
    -                   -> [TcTyVar]    -- Quantify these
    
    883
    +mkInjectivityFDEqn :: [TcTyVar]             -- Quantify these
    
    884
    +                   -> [Bool]                -- Injectivity flags
    
    884 885
                        -> [TcType] -> [TcType]  -- Make these equal
    
    885 886
                        -> FunDepEqns
    
    886 887
     -- When F s1 s2 s3 ~ F t1 t2 t3, and F has injectivity info [True,False,True]
    
    887 888
     --   return the FDEqns { fd_eqs = [Pair s1 t1, Pair s3 t3] }
    
    888
    --- The injectivity flags [Bool] will not all be False, but nothing goes wrong if they are
    
    889
    -mkInjectivityFDEqn inj_args qtvs lhs_args rhs_args
    
    890
    -  = FDEqns { fd_qtvs = qtvs, fd_eqs = eqs }
    
    889
    +-- The injectivity flags [Bool] will not all be False,
    
    890
    +--   but nothing goes wrong if they are
    
    891
    +mkInjectivityFDEqn qtvs inj_args lhs_args rhs_args
    
    892
    +  = assertPpr (let len = length inj_args in
    
    893
    +               len == length lhs_args && len == length rhs_args)
    
    894
    +              (vcat [ text "inj_args:" <+> ppr inj_args
    
    895
    +                    , text "lhs_args:" <+> ppr lhs_args
    
    896
    +                    , text "rhs_args:" <+> ppr rhs_args ]) $
    
    897
    +    -- Need inj_args lhs_args and rhs_args to be same length for zip3
    
    898
    +    FDEqns { fd_qtvs = qtvs, fd_eqs = eqs }
    
    891 899
       where
    
    892 900
         eqs = [ Pair lhs_arg rhs_arg
    
    893 901
               | (True, lhs_arg, rhs_arg) <- zip3 inj_args lhs_args rhs_args ]