Skip to content

Adding Clflags.debug before main loop, as in Toploop - #503

Merged
Octachron merged 2 commits into
ocaml-community:masterfrom
ysalmon:bugfix-backtraces
Jun 23, 2025
Merged

Adding Clflags.debug before main loop, as in Toploop#503
Octachron merged 2 commits into
ocaml-community:masterfrom
ysalmon:bugfix-backtraces

Conversation

@ysalmon

@ysalmon ysalmon commented Jun 20, 2025

Copy link
Copy Markdown
Contributor

An old ocaml commit moved Clflags.debug := true from the module initalisation to their loop function, which we do not call.

So this adds the same just before calling the main (recursive) loop function in utop, both in normal and emacs mode.
Closes #501.

And then we get good backtraces :

─( 09:21:33 )─< command 0 >──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # let rec f (h::t) = h + f t;;

Line 1, characters 10-16:
Warning 8 [partial-match]: this pattern-matching is not exhaustive.
Here is an example of a case that is not matched:
[]

val f : int list -> int = <fun>
─( 09:21:33 )─< command 1 >──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # let g l = f (5::l);;
val g : int list -> int = <fun>
─( 09:21:42 )─< command 2 >──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────{ counter: 0 }─
utop # g [6;3;8];;
Exception: Match_failure ("//toplevel//", 1, 10).
Raised at f in file "//toplevel//", line 1, characters 10-16
Called from f in file "//toplevel//", line 1, characters 23-26
Called from f in file "//toplevel//", line 1, characters 23-26
Called from f in file "//toplevel//", line 1, characters 23-26
Called from f in file "//toplevel//", line 1, characters 23-26
Called from <unknown> in file "//toplevel//", line 1, characters 0-9
Called from Topeval.load_lambda in file "toplevel/byte/topeval.ml", line 93, characters 4-14

@ysalmon
ysalmon requested a review from rgrinberg as a code owner June 20, 2025 07:30
Comment thread src/lib/uTop_main.ml Outdated

@Octachron Octachron left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes looks good to me.

@Octachron
Octachron merged commit 9e025ca into ocaml-community:master Jun 23, 2025
@Octachron

Copy link
Copy Markdown
Member

Merged, this should be part of the upcoming release of utop in preparation of the release of OCaml 5.4.0 .

@ysalmon
ysalmon deleted the bugfix-backtraces branch June 23, 2025 16:20
Octachron added a commit to Octachron/opam-repository that referenced this pull request Jul 25, 2025
CHANGES:

* Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro)
* restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon)
* support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune)
* utop configuration and state files (utoprc, utop-history) are now always in the relevant
  utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy).
* fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov)
* implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron added a commit to Octachron/opam-repository that referenced this pull request Jul 25, 2025
CHANGES:

* Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro)
* restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon)
* support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune)
* utop configuration and state files (utoprc, utop-history) are now always in the relevant
  utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy).
* fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov)
* implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron added a commit to Octachron/opam-repository that referenced this pull request Jul 25, 2025
CHANGES:

* Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro)
* restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon)
* support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune)
* utop configuration and state files (utoprc, utop-history) are now always in the relevant
  utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy).
* fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov)
* implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron added a commit to Octachron/opam-repository that referenced this pull request Jul 25, 2025
CHANGES:

* Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro)
* restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon)
* support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune)
* utop configuration and state files (utoprc, utop-history) are now always in the relevant
  utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy).
* fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov)
* implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron added a commit to Octachron/opam-repository that referenced this pull request Jul 25, 2025
CHANGES:

* Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro)
* restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon)
* support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune)
* utop configuration and state files (utoprc, utop-history) are now always in the relevant
  utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy).
* fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov)
* implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron added a commit to Octachron/opam-repository that referenced this pull request Jul 25, 2025
CHANGES:

* Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro)
* restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon)
* support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune)
* utop configuration and state files (utoprc, utop-history) are now always in the relevant
  utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy).
* fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov)
* implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UTop produces uninformative backtraces

2 participants