Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007060OCaml~DO NOT USE (was: OCaml general)public2015-11-27 14:512017-02-10 17:45
Reportermgiovann 
Assigned Todra 
PrioritylowSeverityfeatureReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version4.02.3 
Target VersionFixed in Version4.05.0 +dev/beta1/beta2/beta3/rc1 
Summary0007060: Toplevel: toplevel swallows exception in installed custom printers
DescriptionWhen 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 ReproduceWith 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 = <printer M.pp_print raised an exception>
Tagsjunior_job
Attached Files

- Relationships

-  Notes
(0014874)
gasche (developer)
2015-11-27 19:28

I think it would be a nice improvement if the error message would also pretty-print the caught exception.
(0017245)
dra (developer)
2017-02-10 13:22

https://github.com/ocaml/ocaml/pull/1035 [^]
(0017247)
dra (developer)
2017-02-10 17:45

Merged GPR#1035

- Issue History
Date Modified Username Field Change
2015-11-27 14:51 mgiovann New Issue
2015-11-27 19:28 gasche Note Added: 0014874
2015-11-27 19:28 gasche Status new => acknowledged
2015-11-28 17:31 gasche Tag Attached: junior_job
2017-02-10 13:22 dra Note Added: 0017245
2017-02-10 17:45 dra Note Added: 0017247
2017-02-10 17:45 dra Status acknowledged => closed
2017-02-10 17:45 dra Assigned To => dra
2017-02-10 17:45 dra Resolution open => fixed
2017-02-10 17:45 dra Fixed in Version => 4.05.0 +dev/beta1/beta2/beta3/rc1
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker