Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toplevel: toplevel swallows exception in installed custom printers #7060

Closed
vicuna opened this issue Nov 27, 2015 · 3 comments
Closed

Toplevel: toplevel swallows exception in installed custom printers #7060

vicuna opened this issue Nov 27, 2015 · 3 comments

Comments

@vicuna
Copy link

vicuna commented Nov 27, 2015

Original bug ID: 7060
Reporter: mgiovann
Assigned to: @dra27
Status: closed (set by @dra27 on 2017-02-10T16:45:41Z)
Resolution: fixed
Priority: low
Severity: feature
Version: 4.02.3
Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Category: ~DO NOT USE (was: OCaml general)
Tags: junior_job
Monitored by: runhang @gasche @diml

Bug description

When evaluating an expression for whose type a custom printer is installed, if the evaluation results in an exception, the toplevel catches the exception but prints the uninformative "printer xx raised an exception" (genprintval.ml 151-152). On the other hand, if the expression has no custom printer installed, the toplevel prints the exception itself.

Note in the below example that the toplevel already prints the type of the expression as if the value were available.

Steps to reproduce

With the following ADT:

module M : sig
type t
val inj : int -> t
val pp_print : Format.formatter -> t -> unit
end = struct
type t = int
let inj n = n
let prj n = if n < 0 then invalid_arg "M" else n
let pp_print pp n = Format.pp_print_int pp (prj n)
end ;;

Then in the toplevel:

M.pp_print Format.std_formatter (M.inj (-3));;

Exception: Invalid_argument "M".

#install_printer M.pp_print;;

M.inj (-3);;

  • : M.t =
@vicuna
Copy link
Author

vicuna commented Nov 27, 2015

Comment author: @gasche

I think it would be a nice improvement if the error message would also pretty-print the caught exception.

@vicuna
Copy link
Author

vicuna commented Feb 10, 2017

Comment author: @dra27

#1035

@vicuna
Copy link
Author

vicuna commented Feb 10, 2017

Comment author: @dra27

Merged #1035

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants