Skip to content

Commit

Permalink
Fix wrong lookup for Mod and Div in GHC >= 9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanG077 committed Apr 12, 2024
1 parent 5cb5e37 commit 0b2507a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog for the [`ghc-typelits-extra`](http://hackage.haskell.org/package/ghc-typelits-extra) package

# Unreleased
* Fix faulty lookup for `Mod` and `Div` in GHC >= 9.2

# 0.4.7
* Fix Plugin silently fails when normalizing <= in GHC 9.4+ [#50](https://github.com/clash-lang/ghc-typelits-extra/issues/50)

Expand Down
7 changes: 3 additions & 4 deletions src-ghc-9.4/GHC/TypeLits/Extra/Solver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ import GHC.TcPluginM.Extra
import GHC.Builtin.Names (eqPrimTyConKey, hasKey, getUnique)
import GHC.Builtin.Types (promotedTrueDataCon, promotedFalseDataCon)
import GHC.Builtin.Types (boolTy, naturalTy, cTupleDataCon, cTupleTyCon)
import GHC.Builtin.Types.Literals (typeNatTyCons)
import GHC.Builtin.Types.Literals (typeNatCmpTyCon)
import GHC.Builtin.Types.Literals (typeNatDivTyCon, typeNatModTyCon, typeNatCmpTyCon)
import GHC.Core.Coercion (mkUnivCo)
import GHC.Core.DataCon (dataConWrapId)
import GHC.Core.Predicate (EqRel (NomEq), Pred (EqPred, IrredPred), classifyPredType)
Expand Down Expand Up @@ -315,8 +314,8 @@ lookupExtraDefs = do
md2 <- lookupModule typeErrModule basePackage
ExtraDefs <$> look md "Max"
<*> look md "Min"
<*> pure (typeNatTyCons !! 5)
<*> pure (typeNatTyCons !! 6)
<*> pure typeNatDivTyCon
<*> pure typeNatModTyCon
<*> look md "FLog"
<*> look md "CLog"
<*> look md "Log"
Expand Down
8 changes: 4 additions & 4 deletions src-pre-ghc-9.4/GHC/TypeLits/Extra/Solver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import GHC.Builtin.Types (boolTy, naturalTy)
#else
import GHC.Builtin.Types (typeNatKind)
#endif
import GHC.Builtin.Types.Literals (typeNatTyCons)
import GHC.Builtin.Types.Literals (typeNatDivTyCon, typeNatModTyCon)
#if MIN_VERSION_ghc(9,2,0)
import GHC.Builtin.Types.Literals (typeNatCmpTyCon)
#else
Expand Down Expand Up @@ -82,7 +82,7 @@ import TyCoRep (Type (..))
import TysWiredIn (typeNatKind, promotedTrueDataCon, promotedFalseDataCon)
import TcTypeNats (typeNatLeqTyCon)
#if MIN_VERSION_ghc(8,4,0)
import TcTypeNats (typeNatTyCons)
import TcTypeNats (typeNatDivTyCon, typeNatModTyCon)
#else
import TcPluginM (zonkCt)
#endif
Expand Down Expand Up @@ -313,8 +313,8 @@ lookupExtraDefs = do
ExtraDefs <$> look md "Max"
<*> look md "Min"
#if MIN_VERSION_ghc(8,4,0)
<*> pure (typeNatTyCons !! 5)
<*> pure (typeNatTyCons !! 6)
<*> pure typeNatDivTyCon
<*> pure typeNatModTyCon
#else
<*> look md "Div"
<*> look md "Mod"
Expand Down

0 comments on commit 0b2507a

Please sign in to comment.