-
Notifications
You must be signed in to change notification settings - Fork 149
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
feat: collect effect constraints to be unified together #7542
base: master
Are you sure you want to change the base?
Conversation
@mlutze This should stay open, right? |
Yes |
c837b23
to
de92f8b
Compare
@mlutze This seems very close to working. Do you need help with debugging? It seems Datalog related. So maybe lowering or something with free variables? I am kind of unsure how you can get those errors we are getting though. |
Ah- its not calling the new solver yet, right? |
Yes, please! I'm thinking maybe I lose part of the substitution somewhere so we end up with free variables that should have been substituted, but I haven't identified the problem yet.
It should be (?) |
Bug is non-deterministic, but this reproduces it always with threads = 1:
|
Removing |
@mlutze @JonathanStarup I have isolated the bug. It has to do with UncheckedMaskingCast. If I remove:
All tests (except one unrelated) run. |
I suspect it has to do with @JonathanStarup Does the verifier not check for effect consistency? E.g. if a sub-expression is control-impure presumable the expression itself must also be control-impure. |
I have a workaround here #7659 It solves nothing, but at least it makes the problem go-away. |
I think now there is just Type.Error left to deal with. |
I think ideally we could treat every Type.Error as a free var. Then any type errors we get out will only be ones we would have no matter what the real value of Type.Error is. What do you think? |
I was thinking constant? |
Ill let you experiment/decide. I don't think the choice right now is important. |
Still transient issues :( |
Do you mean flaky tests? Is it only TestVector that fails? The new solver has no state... So it seems strange. Are we still using Type.minimize? |
I see lots of non-determinism indeed. |
Disabling the optimizer seems to make the tests pass. But what causes the non-determinism which sometimes allows everything to go through? |
@JonathanStarup We are going to need some help debugging this, when you have time. |
One source is the mapping of types to Boolean terms. |
Another source is the naming of variables which affects the solutions computed by the solver (?) |
I think we need the Verifier to reject illegal programs w.r.t effects. |
What's the working thesis: That we produce expressions with non-deterministic effects that are only sometimes wrong and hence only sometimes screwed up by the optimizer? |
Interestingly running EDIT: Add |
In monomorpher, if I compare what source locations are made pure by the strict subst:
it seems that this PR has more source locations made pure, including in e.g.
which at least suggests that more variables are free in this PR... |
main/src/ca/uwaterloo/flix/language/phase/unification/EffUnification2.scala
Show resolved
Hide resolved
@JonathanStarup We believe the bug is in the typer, but we could really benefit from having a verifier that checks effects s.t. the backend does not generate incorrect code. |
Did you have some success or not yet? |
Not yet :( |
@mlutze Do you want to rebase? |
RFM? |
test failures? |
please no |
What a pain. Same issue or new issue? |
Seems new. There's no runtime crash, but apparently a nondeterministic miscompilation. I cannot reliably reproduce. |
Try to compile one of the tests in isolation. That worked last time. |
not working for me :( |
One in about ten run produces false:
|
Add this to
and it shows lots of:
EDIT: Woops, have to be careful and remember arguments could have effects too... |
Observation This is because |
The equality thing is bad, but not the cause. |
fixes #7503