Maybe not so easy question...

Stephen Weeks MLton@sourcelight.com
Sat, 7 Apr 2001 18:11:36 -0700 (PDT)


> Doing, so seems to be tickling a bug related to the way boolean's are
> handled that I don't quite understand...
...
> What I don't understand is where it's finding the "true" constructor as it
> doesn't seem to occur anywhere in the input. I also don't know why the bool
> get's replaced with this "dummy_0" constructor....

The bool datatype gets replaced with a dummy constructor by
remove-unused-constructors.fun (now remove-unused.fun, which combines the old
remove-unused-{constructors,functions,globals}).  A datatype is replaced with
single dummy constructor if it is constructed but never destructed (see line
88).  bool is never destructed, and it is assumed to always be constructed (see
lines 63-4).

As to finding the true constructor, the code in simplify-types.fun (and other
passes as well) assumes that true and false exist (see line 217).

Hopefully it will be enough to add a couple of lines to
remove-unused-constructors so that true and false are never eliminated.  Try
inserting the following two lines at line 65 of remove-unused-constructors.

	  ; setIsDecon Con.truee
	  ; setIsDecon Con.falsee

This bug has already been fixed in our internal version, and probably in the
pre-release version at http://www.sourcelight.com/MLton/EXPERIMENTAL/index.html