Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8a317b6f by Aaron Allen at 2026-01-01T03:05:15-05:00 [#26183] Associated Type Iface Fix When determining "extras" for class decl interface entries, axioms for the associated types need to included so that dependent modules will be recompiled if those axioms change. resolves #26183 - - - - - 7 changed files: - compiler/GHC/Iface/Recomp.hs - + testsuite/tests/driver/recomp26183/M.hs - + testsuite/tests/driver/recomp26183/M2A.hs - + testsuite/tests/driver/recomp26183/M2B.hs - + testsuite/tests/driver/recomp26183/Makefile - + testsuite/tests/driver/recomp26183/all.T - + testsuite/tests/driver/recomp26183/recomp26183.stderr Changes: ===================================== compiler/GHC/Iface/Recomp.hs ===================================== @@ -1782,10 +1782,12 @@ declExtras fix_fn ann_fn rule_env inst_env fi_env dm_env complete_env decl IfaceClass{ifBody = IfConcreteClass { ifSigs=sigs, ifATs=ats }} -> IfaceClassExtras (fix_fn n) insts (ann_fn (AnnOccName n)) meths defms where - insts = (map ifDFun $ (concatMap at_extras ats) - ++ lookupOccEnvL inst_env n) - -- Include instances of the associated types - -- as well as instances of the class (#5147) + insts = + let (atFamInsts, atClsInsts) = foldMap at_extras ats + in (ifFamInstAxiom <$> atFamInsts) ++ (ifDFun <$> atClsInsts) + ++ (ifDFun <$> lookupOccEnvL inst_env n) + -- Include instances and axioms of the associated types + -- as well as instances of the class (#5147) (#26183) meths = [id_extras (getOccName op) | IfaceClassOp op _ _ <- sigs] -- Names of all the default methods (see Note [default method Name]) defms = [ dmName @@ -1802,7 +1804,10 @@ declExtras fix_fn ann_fn rule_env inst_env fi_env dm_env complete_env decl where n = getOccName decl id_extras occ = IdExtras (fix_fn occ) (lookupOccEnvL rule_env occ) (ann_fn (AnnOccName occ)) (lookup_complete_match occ) - at_extras (IfaceAT decl _) = lookupOccEnvL inst_env (getOccName decl) + at_extras (IfaceAT decl _) = + ( lookupOccEnvL fi_env (getOccName decl) -- Axioms + , lookupOccEnvL inst_env (getOccName decl) -- Class instances + ) lookup_complete_match occ = lookupOccEnvL complete_env occ ===================================== testsuite/tests/driver/recomp26183/M.hs ===================================== @@ -0,0 +1,5 @@ +module M where +import M2 + +x :: AT () +x = True ===================================== testsuite/tests/driver/recomp26183/M2A.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TypeFamilies #-} +module M2 where + +class C a where + type AT a + +instance C () where + type AT () = Bool ===================================== testsuite/tests/driver/recomp26183/M2B.hs ===================================== @@ -0,0 +1,8 @@ +{-# LANGUAGE TypeFamilies #-} +module M2 where + +class C a where + type AT a + +instance C () where + type AT () = Int ===================================== testsuite/tests/driver/recomp26183/Makefile ===================================== @@ -0,0 +1,13 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +# Recompilation tests + +recomp26183: + cp M2A.hs M2.hs + '$(TEST_HC)' $(TEST_HC_OPTS) --make M.hs + sleep 1 + cp M2B.hs M2.hs + # This should fail + if '$(TEST_HC)' $(TEST_HC_OPTS) --make M.hs; then false; fi ===================================== testsuite/tests/driver/recomp26183/all.T ===================================== @@ -0,0 +1,3 @@ +test('recomp26183', [extra_files(['M2A.hs', 'M.hs', 'M2B.hs']), + when(fast(), skip), ignore_stdout], + makefile_test, []) ===================================== testsuite/tests/driver/recomp26183/recomp26183.stderr ===================================== @@ -0,0 +1,7 @@ +M.hs:5:5: error: [GHC-83865] + • Couldn't match type ‘Bool’ with ‘Int’ + Expected: AT () + Actual: Bool + • In the expression: True + In an equation for ‘x’: x = True + View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a317b6f6d007b7cb5f2d66184938304... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8a317b6f6d007b7cb5f2d66184938304... You're receiving this email because of your account on gitlab.haskell.org.