Skip to content

Commit

Permalink
Guard the List.hd call in [Show Intros]
Browse files Browse the repository at this point in the history
Fix for [Anomaly: Uncaught exception Failure("hd")] after running [Show
Intros] at the end of a proof:

    Goal True. trivial. Show Intros.
  • Loading branch information
cpitclaudel authored and letouzey committed Jun 22, 2015
1 parent 5089872 commit 192e683
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions toplevel/vernacentries.ml
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,19 @@ let try_print_subgoals () =
let show_intro all =
let pf = get_pftreestate() in
let {Evd.it=gls ; sigma=sigma; } = Proof.V82.subgoals pf in
let gl = {Evd.it=List.hd gls ; sigma = sigma; } in
let l,_= decompose_prod_assum (strip_outer_cast (pf_concl gl)) in
if all
then
let lid = Tactics.find_intro_names l gl in
msg_notice (hov 0 (prlist_with_sep spc pr_id lid))
else
try
let n = List.last l in
msg_notice (pr_id (List.hd (Tactics.find_intro_names [n] gl)))
with Failure "List.last" -> ()
if gls <> [] then begin
let gl = {Evd.it=List.hd gls ; sigma = sigma; } in
let l,_= decompose_prod_assum (strip_outer_cast (pf_concl gl)) in
if all
then
let lid = Tactics.find_intro_names l gl in
msg_notice (hov 0 (prlist_with_sep spc pr_id lid))
else
try
let n = List.last l in
msg_notice (pr_id (List.hd (Tactics.find_intro_names [n] gl)))
with Failure "List.last" -> ()
end

(** Prepare a "match" template for a given inductive type.
For each branch of the match, we list the constructor name
Expand Down

0 comments on commit 192e683

Please sign in to comment.