Fix unsoundness when expanding variant of polymorphic enum #16
+150
−21
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.
unsoundness found in #17:
When typing
opt = X::None1, Thrust allocates new predicate variable (call it p_1 here) for X<{ i32 | p_1 v }>. During the expansion of X::None1: X<{ i32 | p_1 v }>, we have an i32 implicit variable (call it t_1) forSomevariant to be an argument of matcher_pred. The problem here is that t_1: { i32 | p_1 v } is bound to the environment without any constraint, enabling p_1 to be inferred to false to satisfy the entire clauses. This PR introduces a guard to t_1 refinement, making t_1: { i32 | t_d == discr(Some) => p_1 v } (t_d is an implicit variable for the discriminant) to prevent p_1 to be available regardless of the current variant.