Rel: keep RHS uvars abstracted over pattern vars in quasi-pattern solutions (fixes #4587) - #4590
Merged
Merged
Conversation
…rn vars When a non-pattern flex term `?u e1..en` was solved against a rigid RHS by the quasi-pattern rule, the uvars in the RHS were restricted to ctx(?u) alone, so they could no longer mention the variables the solution abstracts over. Restrict them over those binders instead, as the pattern case already does (skipping uvars whose context is already included in ctx(?u)). Also make restrict_ctx drop abstracted binders whose sort mentions a variable that is not in scope (e.g. one bound to a non-variable argument of the quasi-pattern), which would otherwise yield an ill-scoped arrow. Fixes #4587. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #4587.
Since #4515, the unifier solves a bare flex against an applied flex directly. In the repro, that leaves
?w 0 __ __ _v7 =?= hide (?a, ?b)to be solved by the flex-rigid quasi-pattern rule (try_quasi_pattern). That rule restricted the RHS uvars toctx(?w)without abstracting over the quasi-pattern binders. So?b(whose context contained_v7) was narrowed to(a, n)and could no longer be unified with_v7, leaving it unresolved. The gap existed before #4515; the new solve order exposed it.Changes (
FStarC.TypeChecker.Rel):try_quasi_pattern: restrict RHS uvars over the quasi-pattern binders, like the pattern case already does. Uvars whose context is already included in the LHS's context are skipped (no restriction needed). Restricting them anyway changedtests/error-messages/Calc.fstoutput.restrict_ctx: drop abstracted binders whose sort mentions a variable not in scope. In the repro,__: squash (rewrites_to_p n1 0)refers ton1, which had been replaced by the non-variable argument0. Without this the restricted uvar has an ill-scoped type.Added the repro as
pulse/test/bug-reports/Bug4587.fst.Testing:
make -k teston stage3 passes excepttests/custardRelocApp. That test greps forfound here as, and in my workspace the error message wraps between "found" and "here" because of the long absolute path. That looks local to my environment and is unrelated to this change.