PR#7060: [toplevel] Print exceptions in installed custom printers#1035
PR#7060: [toplevel] Print exceptions in installed custom printers#1035dra27 merged 5 commits intoocaml:trunkfrom
Conversation
|
This seems more engineered than it needs to be - with the effect at the moment that it's lost the name of the printer. Does |
Changes
Outdated
| - PR#5163: ocamlobjinfo, dump globals defined by bytecode executables | ||
| (Stéphane Glondu) | ||
|
|
||
| - PR#7060: toplevel, print exceptions in installed custom printers |
There was a problem hiding this comment.
Please include GPR number as well;
PR#7060, GPR#1035: print name of the exception raised in custom printers.
It should also be in section ### Toplevel and debugger: (which will be a new section for this release)
|
Link to Mantis PR |
|
Thanks for the prompt review. |
|
Even with OCaml's relatively small standard library, it can be hard to see the wood for the trees sometimes! However, now I can't make up my mind whether I preferred it saying |
toplevel/genprintval.ml
Outdated
|
|
||
| let exn_printer ppf path = | ||
| fprintf ppf "<printer %a raised an exception>" Printtyp.path path | ||
| let exn_printer ppf path _exn = |
There was a problem hiding this comment.
Sorry for the nitpick, but I find the use of a variable of the form _foo confusing here (and in the rest of the file), given that those variable names are often used for ignored variables, and this variable is very much not ignored. Could you use exn instead?
|
@dra27 I am not sure exactly which output you have in mind, would you show an example? (Generally I would be tempted to not be super-picky: if we don't know which one we prefer, and nobody is going to be strongly negatively affected by the change, then maybe either is fine.) I wonder what is the behavior when the value on which the exception is raised occurs in depth. Is the rest of the value printed correctly, or does the exception abort all printing? Could we have the testcase (a new one or modify the proposed one) to exhibit this behavior? |
|
@gasche The message before was the value itself ( I think it's probably the case that using printers is better? |
|
@gasche The behaviour is to propagate the type t = A | B;;
let print_t f = function A -> Format.fprintf f "A";;
#install_printer print_t;;
type u = X of t | Y;;
X B;;
- : u = X <printer print_t raised an exception: ...>Given that this only alters the string (rather than changing the propagation of the exception), is it really worth a test case too? |
|
I would just use this as a testcase instead of the proposed one, because it is strictly more informative. (Test cases are also used to let people that review patches quickly get a sense of what the changes does, without testing it by themselves.) Re. using the printers: I agree using the printers is better. It seems to be the simplest approach to implement anyway. |
|
@gasche OK, while we were chatting Tadeu has pushed the test! @tadeuzagallo This looks great, thanks - as soon as the CI returns I'll merge. |
|
The only issue I'm seeing is that there's a weird linebreak in the output now: I couldn't figure out why though... |
|
@tadeuzagallo That's not an issue - that's the formatter doing its job and line-wrapping! @gasche Yes, I will (and yes, it is easy to forget, I agree!) |
|
@dra27 That makes sense, thanks for the review and feedback! |
|
The testsuite fails on some of our Continuous Integration machines, but I cannot reproduce the failure at home. For one machine, the content of I suppose that the issue comes from This result comes from a I suspect the issue is not caused by the patch, but the thing we are testing may not be reliable/portable enough. @dra27, do you have access to the CI infrastructure to test this? (Maybe we could skip the test on the affected configurations, or consider disabling it for now to clear the CI again.) |
|
I do have access - I'll try to have a look later. |
|
Hmm - I'm also seeing that with mingw64. |
|
Is there something I can do here to help? |
|
The fix is straightforward - I'm just trying to work out why the CI didn't pick up the problem! |
…aml#1035) Exceptions raised by toplevel printers now include details of the exception itself.
b11eea1 flambda-backend: Introduce Import_info (ocaml#1036) bc5b135 flambda-backend: Fix `ocamlobjinfo` on flambda2 .cmx files (ocaml#1029) c8babbd flambda-backend: Compilation_unit optimisations (ocaml#1035) e8d3e22 flambda-backend: Use 4.14.0 opam switch for building (includes upgrading ocamlformat to 0.24.1) (ocaml#1030) eb14a86 flambda-backend: Port PR81 from ocaml-jst (ocaml#1024) 131bc12 flambda-backend: Merge ocaml-jst 2022-12-13 (ocaml#1022) 06c189a flambda-backend: Make stack allocation the default (ocaml#1013) 98debd5 flambda-backend: Initial support for value slots not of value kind (ocaml#946) deb1714 flambda-backend: Add is_last flag to closinfo words (ocaml#938) d07fce1 flambda-backend: Disable poll insertion in Configure (ocaml#967) 0f1ce0e flambda-backend: Regenerate ocaml/configure autoconf 2.69 (instead of 2.71) (ocaml#1012) 27132d8 flambda-backend: Fix for spurious typing error related to expanding through functor arguments (ocaml#997) 724fb68 flambda-backend: Use `Compilation_unit.t` instead of `Ident.t` for globals (ocaml#871) 396d5b8 flambda-backend: Add a test for frametable setup in natdynlinked libraries (ocaml#983) b73ab12 flambda-backend: Fix invocation of `caml_shared_startup` in native dynlink (ocaml#980) 7c7d75a flambda-backend: Fix split_default_wrapper which did not trigger anymore with flambda2 (ocaml#970) 8fb75bd flambda-backend: Port ocaml#11727 and ocaml#11732 (ocaml#965) fdb7987 flambda-backend: Fix include functor issue after 4.14 merge. (ocaml#948) 9745cdb flambda-backend: Print -dprofile/-dtimings output to stdout like 4.12 (ocaml#943) 5f51f21 flambda-backend: Merge pull request ocaml#932 from mshinwell/4.14-upgrade 841687d flambda-backend: Run make alldepend in ocaml/ (ocaml#936) 72a7658 flambda-backend: Remove reformatting changes only in dynlink/dune (preserving PR889 and adjusting to minimise diff) 6d758cd flambda-backend: Revert whitespace changes in dune files, to match upstream c86bf6e flambda-backend: Remove duplicate tests for polling 971dbeb flambda-backend: Testsuite fixes 32f8356 flambda-backend: Topeval fix for symbols patch befea01 flambda-backend: Compilation fixes / rectify merge faults a84543f flambda-backend: Merge ocaml-jst 8e65056 flambda-backend: Merge ocaml-jst 4d70045 flambda-backend: Remove filename from system frametable (amd64) (ocaml#920) 5e57b7d flambda-backend: Bugfix for runtime frame_descr logic for C frames (ocaml#918) 6423d5e flambda-backend: Merge pull request ocaml#914 from mshinwell/merge-ocaml-jst-2022-10-24 ead605c flambda-backend: Add a missing Extract_exception (ocaml#916) c8f1481 flambda-backend: Resolve conflicts and add specialise/specialised attributes to Builtin_attributes cf4d0d3 flambda-backend: Merge fixes (ocaml#21) c2f742f flambda-backend: Re-enable some tests for Flambda2 (ocaml#881) 3d38d13 flambda-backend: Long frames in frametable (ocaml#797) 85aec7b flambda-backend: Add loop attribute to Builtin_attributes c0f16e3 flambda-backend: Compilation fixes 90dea23 flambda-backend: Merge flambda-backend/main 5acc6ea flambda-backend: Fixes after merge e501946 flambda-backend: Merge ocaml-jst 115083b flambda-backend: Merge ocaml-jst 9943b2e flambda-backend: Revert "Revert "Transform tail-recursive functions into recursive continuations (ocaml#893)"" (ocaml#909) ce339f1 flambda-backend: Fix alloc modes and call kinds for overapplications (ocaml#902) e6a317c flambda-backend: Revert "Transform tail-recursive functions into recursive continuations (ocaml#893)" 853c488 flambda-backend: Transform tail-recursive functions into recursive continuations (ocaml#893) 5a977e4 flambda-backend: Fix missing End_region primitives on switch arms (ocaml#898) 7fa7f9d flambda-backend: Add missing dependencies to Dune files (ocaml#889) 3cd36f0 flambda-backend: Have Lambda `Pgetglobal` and `Psetglobal` take `Compilation_unit.t` (ocaml#896) 7565915 flambda-backend: [@poll error] attribute (ocaml#745) 9eb9448 flambda-backend: Backport the main safepoints PRs (ocaml#740) 689bdda flambda-backend: Add strict mode for ocamldep (ocaml#892) git-subtree-dir: ocaml git-subtree-split: b11eea1
Co-authored-by: Cuihtlauac ALVARADO <[email protected]>
This pull request improves the message printed when exceptions are raised from within installed custom printers (
<printer %s raised an exception>) by adding the caught exception to it.Link to the Mantis PR
Here's what the example from the ocamllabs issue looks like now: