Simon Peyton Jones pushed to branch wip/T27828 at Glasgow Haskell Compiler / GHC Commits: 75745004 by Simon Peyton Jones at 2026-09-24T23:43:34+01:00 Wibbles - - - - - 4 changed files: - compiler/GHC/Core/FamInstEnv.hs - compiler/GHC/Iface/Decl.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/IfaceToCore.hs Changes: ===================================== compiler/GHC/Core/FamInstEnv.hs ===================================== @@ -610,12 +610,14 @@ compareBranches b1@(CoAxBranch { cab_lhs = lhs1, cab_rhs = rhs1 }) -- Here we need the cab_tvs of the two branches to be disinct. -- See Note [CoAxBranch type variables] in GHC.Core.Coercion.Axiom. SurelyApart -> BC_Apart - MaybeApart {} -> pprPanic "compareBranches" (ppr b1 $$ ppr b2) Unifiable subst | Type.substTyAddInScope subst rhs1 `eqType` Type.substTyAddInScope subst rhs2 -> BC_Compat | otherwise -> BC_Incompat + MaybeApart {} -> BC_Incompat + -- An occurs check yields MaybeApart; + -- see Note [Infinitary substitutions] in GHC.Core.Unify where (commonlhs1, commonlhs2) = zipAndUnzip lhs1 lhs2 -- See Note [Compatibility of eta-reduced axioms] ===================================== compiler/GHC/Iface/Decl.hs ===================================== @@ -112,7 +112,7 @@ coAxBranchToIfaceBranch tc lhs_s , ifaxbRoles = roles , ifaxbRHS = toIfaceType rhs , ifaxbIncomps = iface_incomps } - where + where iface_incomps = map (expectJust . flip findIndex lhs_s . eqTypes ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -338,7 +338,12 @@ data IfaceAxBranch = IfaceAxBranch { ifaxbTyVars :: [IfaceTvBndr] , ifaxbRoles :: [Role] , ifaxbRHS :: IfaceType , ifaxbIncomps :: [BranchIndex] } - -- See Note [Storing compatibility] in GHC.Core.Coercion.Axiom + -- We store the incompatibilities in IfaceAxBranch + -- just for (perhaps unnecessary) display purposes: + -- see Note [Displaying axiom incompatibilities] + -- When we construct a real CoAxBranch we compute cab_incomps directly + -- from the equations, ignoring the ifaxbIncomps. + -- We could consider getting rid of ifaxbIncomps altogether. data IfaceConDecls = IfAbstractTyCon -- c.f TyCon.AbstractTyCon ===================================== compiler/GHC/IfaceToCore.hs ===================================== @@ -1111,15 +1111,14 @@ tc_fd (tvs1, tvs2) = do { tvs1' <- mapM tcIfaceTyVar tvs1 ; return (tvs1', tvs2') } tc_ax_branches :: [IfaceAxBranch] -> IfL [CoAxBranch] -tc_ax_branches if_branches = foldlM tc_ax_branch [] if_branches +tc_ax_branches if_branches = mapM tc_ax_branch if_branches -tc_ax_branch :: [CoAxBranch] -> IfaceAxBranch -> IfL [CoAxBranch] -tc_ax_branch prev_branches - (IfaceAxBranch { ifaxbTyVars = tv_bndrs +tc_ax_branch :: IfaceAxBranch -> IfL CoAxBranch +tc_ax_branch (IfaceAxBranch { ifaxbTyVars = tv_bndrs , ifaxbEtaTyVars = eta_tv_bndrs , ifaxbCoVars = cv_bndrs , ifaxbLHS = lhs, ifaxbRHS = rhs - , ifaxbRoles = roles, ifaxbIncomps = _incomps }) + , ifaxbRoles = roles }) = bindIfaceTyConBinders_AT (map (\b -> Bndr (IfaceTvBndr b) (NamedTCB Inferred)) tv_bndrs) $ \ tvs -> -- The _AT variant is needed here; see Note [CoAxBranch type variables] in GHC.Core.Coercion.Axiom @@ -1130,16 +1129,15 @@ tc_ax_branch prev_branches ; this_mod <- getIfModule ; let loc = mkGeneralSrcSpan (fsLit "module " `appendFS` moduleNameFS (moduleName this_mod)) - br = CoAxBranch { cab_loc = loc - , cab_tvs = binderVars tvs - , cab_eta_tvs = eta_tvs - , cab_cvs = cvs - , cab_lhs = tc_lhs - , cab_roles = roles - , cab_rhs = tc_rhs - , cab_overlaps = placeHolderOverlaps - , cab_incomps = placeHolderIncomps } - ; return (prev_branches ++ [br]) } + ; return (CoAxBranch { cab_loc = loc + , cab_tvs = binderVars tvs + , cab_eta_tvs = eta_tvs + , cab_cvs = cvs + , cab_lhs = tc_lhs + , cab_roles = roles + , cab_rhs = tc_rhs + , cab_overlaps = placeHolderOverlaps + , cab_incomps = placeHolderIncomps }) } tcIfaceDataCons :: Name -> TyCon -> IfaceConDecls -> IfL AlgTyConRhs tcIfaceDataCons tycon_name tycon if_cons View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/75745004ef3f28f18a532b015cfe729f... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/75745004ef3f28f18a532b015cfe729f... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Simon Peyton Jones (@simonpj)