Skip to content

Rel: keep RHS uvars abstracted over pattern vars in quasi-pattern solutions (fixes #4587) - #4590

Merged
gebner merged 1 commit into
masterfrom
fix-4587-quasi-pattern-restrict
Sep 24, 2026
Merged

gebner merged 1 commit into
masterfrom
fix-4587-quasi-pattern-restrict

Conversation

@gebner

@gebner gebner commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

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 to ctx(?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 changed tests/error-messages/Calc.fst output.
  • restrict_ctx: drop abstracted binders whose sort mentions a variable not in scope. In the repro, __: squash (rewrites_to_p n1 0) refers to n1, which had been replaced by the non-variable argument 0. Without this the restricted uvar has an ill-scoped type.

Added the repro as pulse/test/bug-reports/Bug4587.fst.

Testing: make -k test on stage3 passes except tests/custard RelocApp. That test greps for found 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.

…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>
@gebner
gebner enabled auto-merge September 24, 2026 05:11
@gebner
gebner added this pull request to the merge queue Sep 24, 2026
Merged via the queue into master with commit c0c03b9 Sep 24, 2026
5 checks passed
@gebner
gebner deleted the fix-4587-quasi-pattern-restrict branch September 24, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pulse regression: eta-expanded witness leaf uvar cannot see an existential opened earlier ("Unexpected unresolved uvars")

1 participant