fix(flambda2-types): Prevent duplicate equations in add_equation #3306
+74
−62
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.
The new meet is cautious about keeping track of whether types are refined during the meet, and uses that information to avoid duplicating equations.
However, this check is only done when performing a meet between an alias and a non-alias type, but not when equations are added through
Typing_env.add_XXX
functions. In particular, equations added when joining environments (throughadd_env_extension_from_level
) are not deduplicated, which can (theoretically) cause the same equation to appear at multiple levels.This patch exposes the
meet_return_value
type to the typing env and uses it to perform duplication directly inadd_equation
. Since we now deduplicate inadd_equation
, we don't need to do it during the meet, which also eliminates a double meet.I suggest hiding whitespace changes to review the changes in the typing env.