-
Notifications
You must be signed in to change notification settings - Fork 0
Better extension from meet #316
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
base: flambda2.0-stable
Are you sure you want to change the base?
Conversation
8cf06c9
to
0792b18
Compare
I've rebased this PR, and updated it a bit: bottom equations in the typing environment are no longer forbidden. I've also got an error when compiling Coq with this branch; I'll investigate this a bit and make a patch (here or a PR on stable) once I've found the cause. |
The bug with Coq seems to be linked to the conversion of exception handlers into regular ones. I don't have all the details yet, but I have some Pop trap actions that point to a continuation that has been turned into a normal continuation.
(cc @mshinwell) |
Maybe #464 can help with the coq bug ? |
Ah, I thought it was merged already. Yes, that's probably the same issue. |
- Introduce a module Meet_result, which allows tracking whether the result the same as one of the arguments or actually more precise. This is used to guarantee that infinite recursive meets are impossible. - Make the functions add_equation and add_env_extension from Tying_env systematically meet the equations. This required patching the join algorithm in Typing_env_level to use these function correctly. - Error when bottom equations are added to the environment. The environment is equivalent to bottom whenever a single of its equations is bottom, so no bottom equations should be added to it. For equations coming from meet, the meet itself can return Bottom. For other equations, the caller must correctly handle the bottom cases before adding the equation.
The goal of this PR is to prevent meet functions from generating spurious extensions, in particular extensions that merely add again the type that is already present.
To do this, I introduce the module
Meet_result
, whose main type is defined as follows:Most
meet
functions are patched to return(t, Typing_env_extension.t) Meet_result.t
instead of(t * Typing_env_extension.t) Or_bottom.t
.Note that in many cases several results are correct. For instance, if both inputs are
Bottom
, then any return value is sound, and purely in terms of approximation all of them exceptNew_result x
, withx
non-bottom, are a best approximation.However, correct detection of spurious extensions require that the following rules are followed:
Both_inputs
must be returnedLeft_input
orRight_input
) must be usedBottom
should be returned, if not thenNew_result
.This PR also contains two adjacent changes:
Or_bottom
type will be used instead).Typing_env
functions have changed to stricter semantics. In particular,add_equation
will always meet the new equation with the existing env, so it is not suitable for replacing existing equations.Typing_env_level.join
has been patched to not rely on this anymore (the previous implementation was likely buggy anyway, asadd_equation
would end up doing a meet in some cases anyway). This patch could be extracted and submitted independently with a bit of work.It also contains a few small fixes for bugs that only showed up with this patch (commits c0dfa82 and 52f85a6). I haven't investigated why they were harmless before the patch, but the fix seems clearly better in both cases.
I've managed to compile Coq with the version of this PR at the time of submission.