From 1363a6f3702a7b4428ff1b8c9c7ffd1446918201 Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Fri, 9 Oct 2020 09:52:42 +0200 Subject: [printing] make detyping resilient to "let x : _ := t in" --- pretyping/detyping.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pretyping/detyping.ml b/pretyping/detyping.ml index 7fcb0795bd..889a30fd76 100644 --- a/pretyping/detyping.ml +++ b/pretyping/detyping.ml @@ -883,7 +883,9 @@ and detype_binder d flags bk avoid env sigma decl c = | BLetIn -> let c = detype d { flags with flg_isgoal = false } avoid env sigma (Option.get body) in (* Heuristic: we display the type if in Prop *) - let s = try Retyping.get_sort_family_of (snd env) sigma ty with _ when !Flags.in_debugger || !Flags.in_toplevel -> InType (* Can fail because of sigma missing in debugger *) in + let s = + try Retyping.get_sort_family_of (snd env) sigma ty + with Retyping.RetypeError _ -> InType (* eg: the type is an evar *) in let t = if s != InProp && not !Flags.raw_print then None else Some (detype d { flags with flg_isgoal = false } avoid env sigma ty) in GLetIn (na', c, t, r) -- cgit v1.2.3 From a96f0868712f725ae3ff7c8fddf54684413bb31c Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Fri, 9 Oct 2020 12:43:31 +0200 Subject: improve comment --- pretyping/detyping.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pretyping/detyping.ml b/pretyping/detyping.ml index 889a30fd76..239a10786b 100644 --- a/pretyping/detyping.ml +++ b/pretyping/detyping.ml @@ -884,8 +884,11 @@ and detype_binder d flags bk avoid env sigma decl c = let c = detype d { flags with flg_isgoal = false } avoid env sigma (Option.get body) in (* Heuristic: we display the type if in Prop *) let s = + (* It can fail if ty is an evar, or if run inside ocamldebug or the + OCaml toplevel since their printers don't have access to sigma/env *) try Retyping.get_sort_family_of (snd env) sigma ty - with Retyping.RetypeError _ -> InType (* eg: the type is an evar *) in + with Retyping.RetypeError _ -> InType + in let t = if s != InProp && not !Flags.raw_print then None else Some (detype d { flags with flg_isgoal = false } avoid env sigma ty) in GLetIn (na', c, t, r) -- cgit v1.2.3 From e58642678bcc40fba51dd012d51c8518b639d0ab Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Fri, 9 Oct 2020 23:34:09 +0200 Subject: Update pretyping/detyping.ml Co-authored-by: Hugo Herbelin --- pretyping/detyping.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pretyping/detyping.ml b/pretyping/detyping.ml index 239a10786b..91c155fcce 100644 --- a/pretyping/detyping.ml +++ b/pretyping/detyping.ml @@ -885,7 +885,7 @@ and detype_binder d flags bk avoid env sigma decl c = (* Heuristic: we display the type if in Prop *) let s = (* It can fail if ty is an evar, or if run inside ocamldebug or the - OCaml toplevel since their printers don't have access to sigma/env *) + OCaml toplevel since their printers don't have access to the proper sigma/env *) try Retyping.get_sort_family_of (snd env) sigma ty with Retyping.RetypeError _ -> InType in -- cgit v1.2.3