Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Fix n <= 0 constraint being reported as impossible. #83

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rowanG077
Copy link
Member

@rowanG077 rowanG077 commented Jun 11, 2024

The problem is in:

let u' = substsSOP subst (subtractIneq u)
x' = substsSOP subst x
y' = substsSOP subst y
uS = (x',y',b)
leqsG' | isGiven (ctEvidence ct) = (x',y',b):leqsG
| otherwise = leqsG
ineqs = concat [ leqsG
, map (substLeq subst) leqsG
, map snd (rights (map fst eqsG))
]
tcPluginTrace "unifyNats(ineq) results" (ppr (ct,u,u',ineqs))
case runWriterT (isNatural u') of
Just (True,knW) -> do
evs' <- maybe evs (:evs) <$> evMagic ct knW (subToPred opts leqT k)
simples subst evs' leqsG' xs eqs'
Just (False,_) | null k -> return (Impossible (fst eq))
_ -> do
let solvedIneq = mapMaybe runWriterT

Given a constraint of a <= 0 then subtractIneq will turn that into -a and isNatural will report it as not a natural. The approach in this PR obviously doesn't work. There is a ton of fallout in the other plugins... So I need to think of something else.

The first commit tried a "proper" fix but there is fallout of tests failing on old GHCs and I tried to compile clash-compiler with it and a ton of breakage occured in ghc-typelits-extra. The second commit added a hack which does not have the problem of fallout. But doesn't work on older GHC due to a <= 0 turning up as a wanted.

Pinging the guru @christiaanb.

@rowanG077 rowanG077 changed the title Fix n <= 0 constrained being reported as impossible. WIP: Fix n <= 0 constrained being reported as impossible. Jun 11, 2024
@rowanG077 rowanG077 force-pushed the fix-le-zero-impossible branch 2 times, most recently from a1ba98e to 3bc9f4d Compare June 11, 2024 18:55
@rowanG077 rowanG077 force-pushed the fix-le-zero-impossible branch from 3bc9f4d to f2e314d Compare June 11, 2024 19:07
@rowanG077 rowanG077 changed the title WIP: Fix n <= 0 constrained being reported as impossible. WIP: Fix n <= 0 constraint being reported as impossible. Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant