[Git][ghc/ghc][wip/soulomoon/T26154-work-around] Fix crash in family instance consistency checking

Patrick pushed to branch wip/soulomoon/T26154-work-around at Glasgow Haskell Compiler / GHC Commits: 04ed1efa by soulomoon at 2025-07-02T22:12:15+08:00 Fix crash in family instance consistency checking Modules from ModIface Dependencies and home package family instance environment (built from module graph) are not always consistent. Use empty family instance environment when module is not found instead of crashing during checkFamInstConsistency. Fix #26154 - - - - - 1 changed file: - compiler/GHC/Tc/Instance/Family.hs Changes: ===================================== compiler/GHC/Tc/Instance/Family.hs ===================================== @@ -405,7 +405,13 @@ getFamInsts hpt_fam_insts mod | Just env <- lookupModuleEnv hpt_fam_insts mod = return env | otherwise = do { _ <- initIfaceTcRn (loadSysInterface doc mod) ; eps <- getEps - ; return (expectJust $ + -- Workaround for #26154: + -- We use `fromMaybe emptyFamInstEnv` instead of `expectJust` because + -- the module `mod` comes from the `ModIface`'s `Dependencies`, while + -- `hpt_fam_insts` is built from `moduleGraphModulesBelow`. + -- Due to inconsistencies between the two, `mod` might not be present + -- in `hpt_fam_insts`. + ; return (fromMaybe emptyFamInstEnv $ lookupModuleEnv (eps_mod_fam_inst_env eps) mod) } where doc = ppr mod <+> text "is a family-instance module" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04ed1efa2e63a698b143f0c26a5b36fc... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/04ed1efa2e63a698b143f0c26a5b36fc... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Patrick (@soulomoon)