Skip to content

Commit

Permalink
Merge PR coq#19769: Fixes coq#17314: Tactic unification may leave unb…
Browse files Browse the repository at this point in the history
…ound de Bruijn indices when unifying holes under a "fun"

Reviewed-by: ppedrot
Co-authored-by: ppedrot <[email protected]>
  • Loading branch information
coqbot-app[bot] and ppedrot authored Jan 7, 2025
2 parents 9c470a2 + 6d3ee83 commit 003b300
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- **Fixed:**
Unbound variables were sometimes generated when a metavariable of a
theorem given to :tacn:`apply` occurred in the type of the theorem
under a :n:`fun`
(`#19769 <https://github.com/coq/coq/pull/19769>`_,
fixes `#17314 <https://github.com/coq/coq/issues/17314>`_,
by Hugo Herbelin).
2 changes: 1 addition & 1 deletion pretyping/unification.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1846,7 +1846,7 @@ let w_merge env with_types flags (substn : subst0) =
in
w_merge_rec metas0 evd' metas evars' eqns
| _ ->
let evd', metas0, rhs'' = pose_all_metas_as_evars ~metas:metas0 curenv evd rhs' in
let evd', metas0, rhs'' = pose_all_metas_as_evars ~metas:metas0 env evd rhs' in
let evd' =
try solve_simple_evar_eqn eflags curenv evd' ev rhs''
with Retyping.RetypeError _ -> error_cannot_unify curenv evd' (mkEvar ev, rhs'')
Expand Down
13 changes: 13 additions & 0 deletions test-suite/bugs/bug_17314.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Definition arrow_apply (f : Prop -> Prop) := True -> f True. (* We need True-> to trigger a unification in an extended context *)

Definition something (x : Prop) := arrow_apply (fun _ => x).

Axiom trivial: forall l1: Prop, something l1 -> something l1.

Lemma t : exists f, arrow_apply f.
eexists.
unshelve apply trivial.
(* was giving "something ?l1@{t:=_UNBOUND_REL_1}" while the evar is not supposed to depend on t *)
(* so, we check that, indeed, t is not here *)
match goal with [ H : True |- _ ] => fail 1 | _ => idtac end.
Abort.

0 comments on commit 003b300

Please sign in to comment.