Skip to content

Commit a1ba98e

Browse files
committed
Hack attempt #2
1 parent 689bb50 commit a1ba98e

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src-ghc-9.4/GHC/TypeLits/Normalise.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,9 @@ simplifyNats opts@Opts {..} leqT eqsG eqsW = do
507507
x' = substsSOP subst x
508508
y' = substsSOP subst y
509509
uS = (x',y',b)
510-
leqsG' | isGiven (ctEvidence ct) = (x',y',b):leqsG
511-
| otherwise = leqsG
510+
isG = isGiven (ctEvidence ct)
511+
leqsG' | isG = (x',y',b):leqsG
512+
| otherwise = leqsG
512513
ineqs = concat [ leqsG
513514
, map (substLeq subst) leqsG
514515
, map snd (rights (map fst eqsG))
@@ -519,7 +520,7 @@ simplifyNats opts@Opts {..} leqT eqsG eqsW = do
519520
evs' <- maybe evs (:evs) <$> evMagic ct knW (subToPred opts leqT k)
520521
simples subst evs' leqsG' xs eqs'
521522

522-
Just (False,_) | null k -> return (Impossible (fst eq))
523+
Just (False,_) | null k && not isG -> return (Impossible (fst eq))
523524
_ -> do
524525
let solvedIneq = mapMaybe runWriterT
525526
-- it is an inequality that can be instantly solved, such as

src/GHC/TypeLits/Normalise/Unify.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,8 @@ unifiers' ct (S ((P [I i]):ps1)) (S ((P [I j]):ps2))
568568
unifiers' ct s1@(S ps1) s2@(S ps2) = case sopToIneq k1 of
569569
Just (s1',s2',_)
570570
| s1' /= s1 || s2' /= s1
571-
, maybe False (uncurry (&&) . second Set.null) (runWriterT (isNatural s1'))
572-
, maybe False (uncurry (&&) . second Set.null) (runWriterT (isNatural s2'))
571+
, maybe True (uncurry (&&) . second Set.null) (runWriterT (isNatural s1'))
572+
, maybe True (uncurry (&&) . second Set.null) (runWriterT (isNatural s2'))
573573
-> unifiers' ct s1' s2'
574574
_ | null psx
575575
, length ps1 == length ps2
@@ -655,7 +655,7 @@ isNatural (S []) = return True
655655
isNatural (S [P []]) = return True
656656
isNatural (S [P (I i:ps)])
657657
| i >= 0 = isNatural (S [P ps])
658-
| otherwise = WriterT Nothing
658+
| otherwise = return False
659659
-- If i is not a natural number then their sum *might* be natural,
660660
-- but we simply can't be sure since ps might be zero
661661
isNatural (S [P (V _:ps)]) = isNatural (S [P ps])

tests/Tests.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,12 @@ oneLtPowSubst = go
509509
go = id
510510

511511
givenLEZeroNotImpossible :: forall (a :: Nat) . Proxy a -> a <= 0 => ()
512-
givenLEZeroNotImpossible _ = go (Proxy @(a + a - a))
512+
givenLEZeroNotImpossible p = go (go2 p)
513513
where
514+
-- Ensure the plugin is called
515+
go2 :: Proxy (b + 0) -> Proxy b
516+
go2 p = p
517+
514518
go :: Proxy b -> b <= 0 => ()
515519
go _ = ()
516520

0 commit comments

Comments
 (0)