Skip to content

Commit ac62cda

Browse files
committed
Fix bug rocq-prover#4101, noccur_evar's expand_projection can legitimately fail
when called from w_unify, so we protect it.
1 parent e77f178 commit ac62cda

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

pretyping/evarsolve.ml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,13 @@ let noccur_evar env evd evk c =
192192
(match pi2 (Environ.lookup_rel i env) with
193193
| None -> ()
194194
| Some b -> cache := Int.Set.add (i-k) !cache; occur_rec acc (lift i b))
195-
| Proj (p,c) -> occur_rec acc (Retyping.expand_projection env evd p c [])
195+
| Proj (p,c) ->
196+
let c =
197+
try Retyping.expand_projection env evd p c []
198+
with Retyping.RetypeError _ ->
199+
(* Can happen when called from w_unify which doesn't assign evars/metas
200+
eagerly enough *) c
201+
in occur_rec acc c
196202
| _ -> iter_constr_with_full_binders (fun rd (k,env) -> (succ k, push_rel rd env))
197203
occur_rec acc c
198204
in

test-suite/bugs/closed/4101.v

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(* File reduced by coq-bug-finder from original input, then from 10940 lines to 152 lines, then from 509 lines to 163 lines, then from 178 lines to 66 lines *)
2+
(* coqc version 8.5beta1 (March 2015) compiled on Mar 2 2015 18:53:10 with OCaml 4.01.0
3+
coqtop version cagnode15:/afs/csail.mit.edu/u/j/jgross/coq-8.5,v8.5 (e77f178e60918f14eacd1ec0364a491d4cfd0f3f) *)
4+
5+
Global Set Primitive Projections.
6+
Set Implicit Arguments.
7+
Record sigT {A} (P : A -> Type) := existT { projT1 : A ; projT2 : P projT1 }.
8+
Axiom path_forall : forall {A : Type} {P : A -> Type} (f g : forall x : A, P x),
9+
(forall x, f x = g x) -> f = g.
10+
Lemma sigT_obj_eq
11+
: forall (T : Type) (T0 : T -> Type)
12+
(s s0 : forall s : sigT T0,
13+
sigT (fun _ : T0 (projT1 s) => unit) ->
14+
sigT (fun _ : T0 (projT1 s) => unit)),
15+
s0 = s.
16+
Proof.
17+
intros.
18+
Set Debug Tactic Unification.
19+
apply path_forall.

0 commit comments

Comments
 (0)