Skip to content
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

fix(flambda2-types): Prevent duplicate equations in add_equation #3306

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bclement-ocp
Copy link
Contributor

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 (through add_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 in add_equation. Since we now deduplicate in add_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.

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 (through `add_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 in `add_equation`. Since we now
deduplicate in `add_equation`, we don't need to do it during the meet,
which also eliminates a double meet.
@bclement-ocp bclement-ocp added the flambda2 Prerequisite for, or part of, flambda2 label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flambda2 Prerequisite for, or part of, flambda2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant