[Git][ghc/ghc][master] Fix crash in Data.Data instance for HsCtxt
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 98c20394 by sheaf at 2026-06-10T05:11:09-04:00 Fix crash in Data.Data instance for HsCtxt The Data.Data instance for HsCtxt contained an error for the 'toConstr' method, which could trigger for example when looking at -ddump-tc-ast traces. Replace it with the 'abstractConstr' pattern used in the rest of the codebase. - - - - - 2 changed files: - + changelog.d/T27359 - compiler/GHC/Hs/Instances.hs Changes: ===================================== changelog.d/T27359 ===================================== @@ -0,0 +1,9 @@ +section: compiler +issues: #27359 +mrs: !16142 +synopsis: + Fix ``Data.Data`` instance of ``HsCtxt`` to avoid a crash +description: + The ``toConstr`` method of the ``Data.Data`` instance of ``HsCtxt`` now + uses ``abstractConstr`` instead of ``error``, which avoids it triggering + runtime crashes (e.g. when using ``-ddump-tc-ast``). ===================================== compiler/GHC/Hs/Instances.hs ===================================== @@ -46,6 +46,7 @@ import GHC.Hs.ImpExp import GHC.Parser.Annotation import GHC.Types.Name.Reader (WithUserRdr(..)) import GHC.Types.InlinePragma (ActivationGhc) +import GHC.Utils.Misc (abstractConstr) import GHC.Data.BooleanFormula (BooleanFormula(..)) import Language.Haskell.Syntax.Decls import Language.Haskell.Syntax.Decls.Foreign (CType(..), Header(..)) @@ -673,7 +674,7 @@ deriving instance Eq (IE GhcTc) instance Data HsCtxt where gunfold _ _ _ = error "no gunfold for HsCtxt" gfoldl _ k z = k z - toConstr = error "no toConstr for HsCtxt" + toConstr _ = abstractConstr "HsCtxt" dataTypeOf = error "no dataTypeOf for HsCtxt" deriving instance Data XXExprGhcRn View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/98c20394e8a130df928272c360199fb5... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/98c20394e8a130df928272c360199fb5... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)