Skip to content

Instantly share code, notes, and snippets.

@mjambon
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjambon/4c4931d97c212efc7b5b to your computer and use it in GitHub Desktop.
Save mjambon/4c4931d97c212efc7b5b to your computer and use it in GitHub Desktop.
Empty stack trace for BatString.split depending on I don't know what.
(*
Both calls to BatString.split and List.assoc below
raise Not_found. The stack trace shouldn't be empty
in either case, but it is empty under certain mysterious
circumstances for BatString.split.
#use "topfind";;
#require "batteries";;
*)
let debug_this () =
(* Known to not produce a backtrace sometimes. Trying to find out
under which conditions *)
let split_test () =
try
ignore (BatString.split "" "x");
false
with e ->
Printexc.get_backtrace () <> ""
in
(* Known to produce a backtrace even when BatString.split doesn't *)
let assoc_test () =
try
ignore (List.assoc 0 []);
false
with e ->
Printexc.get_backtrace () <> ""
in
Printexc.record_backtrace true;
assert (assoc_test ());
Printf.eprintf "***** %s\n%!"
(if split_test () then "SUCCESS" else "FAILURE")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment