Skip to content

Commit b00f7cd

Browse files
committed
Merge remote-tracking branch 'github/pr/333' into v8.5
Was PR#233: Fix a bug in error printing of unif constraints
2 parents b63a5cf + 52a37da commit b00f7cd

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

pretyping/evarconv.ml

+9-6
Original file line numberDiff line numberDiff line change
@@ -1158,9 +1158,14 @@ let apply_conversion_problem_heuristic ts env evd pbty t1 t2 =
11581158
(* Some head evar have been instantiated, or unknown kind of problem *)
11591159
evar_conv_x ts env evd pbty t1 t2
11601160

1161+
let error_cannot_unify env evd pb ?reason t1 t2 =
1162+
Pretype_errors.error_cannot_unify_loc
1163+
(loc_of_conv_pb evd pb) env
1164+
evd ?reason (t1, t2)
1165+
11611166
let check_problems_are_solved env evd =
11621167
match snd (extract_all_conv_pbs evd) with
1163-
| (pbty,env,t1,t2)::_ -> Pretype_errors.error_cannot_unify env evd (t1, t2)
1168+
| (pbty,env,t1,t2) as pb::_ -> error_cannot_unify env evd pb t1 t2
11641169
| _ -> ()
11651170

11661171
let max_undefined_with_candidates evd =
@@ -1229,17 +1234,15 @@ let consider_remaining_unif_problems env
12291234
aux evd pbs progress (pb :: stuck)
12301235
end
12311236
| UnifFailure (evd,reason) ->
1232-
Pretype_errors.error_cannot_unify_loc (loc_of_conv_pb evd pb)
1233-
env evd ~reason (t1, t2))
1237+
error_cannot_unify env evd pb ~reason t1 t2)
12341238
| _ ->
12351239
if progress then aux evd stuck false []
12361240
else
12371241
match stuck with
12381242
| [] -> (* We're finished *) evd
12391243
| (pbty,env,t1,t2 as pb) :: _ ->
1240-
(* There remains stuck problems *)
1241-
Pretype_errors.error_cannot_unify_loc (loc_of_conv_pb evd pb)
1242-
env evd (t1, t2)
1244+
(* There remains stuck problems *)
1245+
error_cannot_unify env evd pb t1 t2
12431246
in
12441247
let (evd,pbs) = extract_all_conv_pbs evd in
12451248
let heuristic_solved_evd = aux evd pbs false [] in

pretyping/evd.ml

+11
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ let set_universe_context evd uctx' =
840840
{ evd with universes = uctx' }
841841

842842
let add_conv_pb ?(tail=false) pb d =
843+
(** MS: we have duplicates here, why? *)
843844
if tail then {d with conv_pbs = d.conv_pbs @ [pb]}
844845
else {d with conv_pbs = pb::d.conv_pbs}
845846

@@ -1888,6 +1889,16 @@ let print_env_short env =
18881889

18891890
let pr_evar_constraints pbs =
18901891
let pr_evconstr (pbty, env, t1, t2) =
1892+
let env =
1893+
(** We currently allow evar instances to refer to anonymous de
1894+
Bruijn indices, so we protect the error printing code in this
1895+
case by giving names to every de Bruijn variable in the
1896+
rel_context of the conversion problem. MS: we should rather
1897+
stop depending on anonymous variables, they can be used to
1898+
indicate independency. Also, this depends on a strategy for
1899+
naming/renaming. *)
1900+
Namegen.make_all_name_different env
1901+
in
18911902
print_env_short env ++ spc () ++ str "|-" ++ spc () ++
18921903
print_constr_env env t1 ++ spc () ++
18931904
str (match pbty with

toplevel/himsg.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ let pr_constraints printenv env sigma evars cstrs =
741741
let evs =
742742
prlist
743743
(fun (ev, evi) -> fnl () ++ pr_existential_key sigma ev ++
744-
str " : " ++ pr_lconstr_env env' sigma evi.evar_concl) l
744+
str " : " ++ pr_lconstr_env env' sigma evi.evar_concl ++ fnl ()) l
745745
in
746746
h 0 (pe ++ evs ++ pr_evar_constraints cstrs)
747747
else

0 commit comments

Comments
 (0)