[MLton] Question: What does 'toplevel handler not installed' mean?

Matthew Fluet fluet@cs.cornell.edu
Wed, 14 Jul 2004 17:46:23 -0400 (EDT)


> Just for fun I tried bootstrapping Mingwin again,
> but got this error (which is at least, no longer the
> "Path Exception" error):
>
> /c/fulgham/projects/mlton.mingwin/build/lib/mlton-compile
> @MLton --
> /c/fulgham/projects/mlton.mingwin/build/lib/world
> MLton bug: toplevel handler not installed.
> Please send a bug report to MLton@mlton.org.
> make[1]: *** [world-no-check] Error 2

Essentially, the top-level exception handler is "installed" by the Basis
Library (see /basis-library/mlton/{mlton.sml,exn.sml}).

Most likely, what you are seeing is an exception being raised by the Basis
Library implementation before it gets to the point of installing the
handler.  Don't know exactly what, but there aren't too many things that
do _real_ computation in the Basis Library.

The thing to try is to move
  "mlton/exn.{sig,sml}"
as early as possible in
  /basis-library/libs/build
You can probably get it all they way up to just after "text/string.sml".
Then move
  "Primitive.TopLevel.setHandler MLtonExn.topLevelHandler"
from /basis-library/mlton/mlton.sml
to /basis-library/mlton/exn.sml
as
  "Primitive.TopLevel.setHandler topLevelHandler"

The net effect of this is to install the exception handler earlier,
hopefully before the point where the exception is raised.  Then you ought
to see the actual exception name, which ought to help track down what is
causing it.