Add weak kvars - #1579
Conversation
|
@nilehmann I'm getting some failing tests relating to https://github.com/flux-rs/flux/blob/ck-add-wkvars/crates/flux-infer/src/infer.rs#L1045-L1048 One of the compared sides has weak kvars added to its function signature and the other does not. There are a couple possible answers I can imagine:
Also the occurs check failure is occurring in tock now... I can't remember if I did anything or if it resolved itself. https://github.com/flux-rs/flux/blob/ck-add-wkvars/crates/flux-refineck/src/type_env.rs#L552-L555 Your thoughts? |
|
@cole-k We should not add weak kvars to function pointers. It's theoretically possible to add refinement to function pointers, but we currently don't have the necessary checks, so the assumption is that function pointers never have refinements, hence the assertion. |
I just pushed a commit that lets you turn off wkvar adding wherever we call Or do I need to do something else to ensure |
|
Function pointers don't go through the |
|
@nilehmann per our discussion I ignored BOTH This might break some of the tests in our benchmarks, but I think it's unlikely since most traits are things we are using not modifying. EDIT: Also the occurs check is failing in tock too, so I'll take a look at that now… |
|
We think you can have wkvars in both |
whenever we merge the other changes on top of this, we should first put these changes in so that the rebase isn't as miserable
should have done this a long time ago
|
Circling back to this before I get busy because of other stuff. I think we can do away with the wkvar UIF encoding, at least for this PR. We can decide for the one that introduces and uses wick whether or not to add it. The good news is that I have some (perhaps untrustworthy) changes which (1) implement fusion in flux correctly and (2) avoid sending wkvars as UIFs off to fixpoint as a result --- they do depend on some changes in Haskell fixpoint, but we can discuss if they are reasonable or not at a later time. So there is hope yet that we can do away with the UIF encoding in the limit. Immediate next step is to open as a PR and add description. Next step after merging this in is to rebase ck-refinement-suggestions on top (may be a bit messy). |
This PR adds support for weak, or external kvars. These are inference variables which fixpoint (usually) can't natively handle because they tend to appear only in either head position (meaning they can trivially be solved to true) or body position (meaning they can be trivially solved to false).
We generate weak kvars on function signatures, representing holes that can be filled in with refinements. The intended use for theses is for inferring function signatures to fix type errors.
There are some caveats to the code introduced here.