packages feed

ghc-tcplugin-api 0.18.0.0 → 0.18.1.0

raw patch · 3 files changed

+19/−7 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

changelog.md view
@@ -1,9 +1,14 @@ 
+# Version 0.18.1.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
   Given constraints. That is, all flattening skolems `[G] fsk ~ F tys` will be
-  substitute away, both in Givens and in Wanteds/Deriveds.
+  substituted away, both in Givens and in Wanteds/Deriveds.
 
   No change for GHC 9.2 and above, as GHC stopped producing flattening variables
   from 9.2 onwards.
ghc-tcplugin-api.cabal view
@@ -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
src/GHC/TcPlugin/API/TyConSubst.hs view
@@ -2,6 +2,7 @@ 
 {-# LANGUAGE BangPatterns        #-}
 {-# LANGUAGE LambdaCase          #-}
+{-# LANGUAGE MultiWayIf          #-}
 {-# LANGUAGE NamedFieldPuns      #-}
 {-# LANGUAGE RecordWildCards     #-}
 {-# LANGUAGE ScopedTypeVariables #-}
@@ -403,7 +404,6 @@       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 @@       | 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 @@         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