diff --git a/changelog.md b/changelog.md index c678b57..9cfd0cb 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,9 @@ +# Version 0.18.0.0 (2025-10-09) + +- Bugfix for v0.18.0.0: deal with constraints generated by unflattening + in `splitTyConApp_upTo`. Fixes #19. + # Version 0.18.0.0 (2025-09-15) - On GHC 9.0 and below, `ghc-tcplugin-api` will now automatically unflatten all diff --git a/ghc-tcplugin-api.cabal b/ghc-tcplugin-api.cabal index c332df4..8ec0c01 100644 --- a/ghc-tcplugin-api.cabal +++ b/ghc-tcplugin-api.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: ghc-tcplugin-api -version: 0.18.0.0 +version: 0.18.1.0 synopsis: An API for type-checker plugins. license: BSD-3-Clause build-type: Simple diff --git a/src/GHC/TcPlugin/API/TyConSubst.hs b/src/GHC/TcPlugin/API/TyConSubst.hs index 3196a62..2e0cd04 100644 --- a/src/GHC/TcPlugin/API/TyConSubst.hs +++ b/src/GHC/TcPlugin/API/TyConSubst.hs @@ -2,6 +2,7 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiWayIf #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -403,7 +404,6 @@ isCanonicalVarEq = \case Just (cc_tyvar, cc_rhs, cc_eq_rel) CFunEqCan { cc_fsk, cc_fun, cc_tyargs } -> Just (cc_fsk, mkTyConApp cc_fun cc_tyargs, NomEq) - _otherwise -> Nothing #elif __GLASGOW_HASKELL__ < 907 CEqCan { cc_lhs, cc_rhs, cc_eq_rel } | TyVarLHS var <- cc_lhs @@ -411,8 +411,6 @@ isCanonicalVarEq = \case | TyFamLHS tyCon args <- cc_lhs , Just var <- getTyVar_maybe cc_rhs -> Just (var, mkTyConApp tyCon args, NomEq) - _otherwise - -> Nothing #else CEqCan eqCt | TyVarLHS var <- lhs @@ -424,9 +422,18 @@ isCanonicalVarEq = \case lhs = eq_lhs eqCt rhs = eq_rhs eqCt rel = eq_eq_rel eqCt - _otherwise - -> Nothing #endif + -- Deal with CNonCanonical, which are produced by ghc-tcplugin-api + -- in GHC 9.0 and below due to 'unflattenCts'. + ct@(CNonCanonical {}) + | EqPred rel lhs rhs <- classifyPredType (ctPred ct) + -> if | Just tv <- getTyVar_maybe lhs + -> Just (tv, rhs, rel) + | Just tv <- getTyVar_maybe rhs + -> Just (tv, lhs, rel) + | otherwise + -> Nothing + _ -> Nothing {------------------------------------------------------------------------------- Internal auxiliary