flambda2-types: Prevent accidentally recursive meet #4397
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are some situations (particularly with extensions stored on a
variable
xthat add new equations for that same variablex) thatcauses the current (and the previous) meet algorithm to go into an
infinite loop. The rest of the code is carefully written to avoid these
situations, but this is hampering recent work in the typing env (#4112
and #3538 are carefully working around this).
The proper long term fix for the issue is not clear. It might be similar
to what is done in #4112, where extensions are associated with
identifiers to avoid adding extensions recursively, if we want to allow
recursive extensions. Or it might be some clever mechanism to extract
recursive equations from extensions and lift them to the point of the
disjunction.
In the short term, this patch uses the
meet_envfrom #4269 and #4278in order to keep track of variables we are currently adding an equation
for, and simply dropping a second occurence of the same variable: if
this happens, we are likely entering an infinite loop of trying to add
the same equation recursively, so we simply drop the inner equation.
This should not happen currently, however it is going to start happening
when we start tracking the
Is_intandGet_tagvalues of blocks forthe match-in-match heuristics.
Note: this PR includes (and is rebased on top of) #4278 ; only the latest commit is new in this PR.