ghc-tcplugin-api 0.7.0.0 → 0.7.1.0
raw patch · 3 files changed
+25/−16 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- GHC.TcPlugin.API: newDerived :: MonadTcPluginWork m => CtLoc -> PredType -> m CtEvidence
Files
- changelog.md +11/−0
- ghc-tcplugin-api.cabal +1/−1
- src/GHC/TcPlugin/API.hs +13/−15
changelog.md view
@@ -1,4 +1,15 @@ +# Version 0.7.1.0 (2022-01-04) + +- `newWanted` now always uses the `CtLoc` information that it is provided with, + as opposed to obtaining some information from the monadic environment. + This means you no longer need to wrap calls to `newWanted` in `setCtLocM` + to ensure that GHC reports the correct source span when reporting unsolved + Wanteds in error messages. + +- Remove the `newDerived` function, as Derived constraints are going to be + removed from GHC. + # Version 0.7.0.0 (2021-12-31) - Re-export functions for dealing with type-level literals,
ghc-tcplugin-api.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: ghc-tcplugin-api -version: 0.7.0.0 +version: 0.7.1.0 synopsis: An API for type-checker plugins. license: BSD-3-Clause build-type: Simple
src/GHC/TcPlugin/API.hs view
@@ -315,7 +315,7 @@ -- -- GHC 9.4 removes this flavour of constraints entirely, subsuming their uses into -- Wanted constraints. - , askDeriveds, newDerived + , askDeriveds -- ** Location information and 'CtLoc's @@ -786,24 +786,23 @@ -------------------------------------------------------------------------------- --- | Create a new derived constraint. +-- | Create a new Wanted constraint. -- -- Requires a location (so that error messages can say where the constraint came from, -- what things were in scope at that point, etc), as well as the actual constraint (encoded as a type). newWanted :: MonadTcPluginWork m => CtLoc -> PredType -> m CtEvidence -newWanted loc pty = liftTcPluginM $ GHC.newWanted loc pty - --- | Create a new derived constraint. See also 'newWanted'. -newDerived :: MonadTcPluginWork m => CtLoc -> PredType -> m CtEvidence -newDerived loc pty = liftTcPluginM $ GHC.newDerived loc pty +newWanted loc pty = +#if !HAS_REWRITING + -- On GHC 9.2 and below, 'newWanted' doesn't use the location information + -- that is passed to it, retrieving it from the 'TcM' environment instead. + -- https://gitlab.haskell.org/ghc/ghc/-/issues/20895 + setCtLocM loc $ +#endif + liftTcPluginM $ GHC.newWanted loc pty --- | Create a new given constraint. --- --- Unlike 'newWanted' and 'newDerived', we need to supply evidence --- for this constraint. +-- | Create a new Given constraint. -- --- Use 'setCtLocM' to pass along the location information, --- as only the 'CtOrigin' gets taken into account here. +-- Unlike 'newWanted', we need to supply evidence for this constraint. newGiven :: CtLoc -> PredType -> EvExpr -> TcPluginM Solve CtEvidence newGiven loc pty evtm = do #if HAS_REWRITING @@ -823,8 +822,7 @@ rewriteEnvCtLoc :: RewriteEnv -> CtLoc rewriteEnvCtLoc = fe_loc --- | Set the location information for a computation, --- so that the constraint solver reports an error at the given location. +-- | Set the location information for a computation. setCtLocM :: MonadTcPluginWork m => CtLoc -> m a -> m a setCtLocM loc = unsafeLiftThroughTcM ( GHC.setCtLocM loc )