-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with SML/NJ-built mlton
: SML/NJ does not support EXACT
formatting of reals
#523
Comments
By the way, I've confirmed that, with this change, I'm able to build |
Something must be wrong with the way the SML/NJ stubs are working, because that's supposed to be handled:
The |
I also don't know why |
Gotcha, this makes sense. I figured this might be something that the stubs were (supposed to be) handling... but not sure what's going wrong. I'll take a closer look later, or let me know what you find if you get to it first! |
Closes MLton#523 Although SML/NJ 110.99.3 fixed some issues with `structure Real{,64}` failing to match the SML Basis Library specification, it did not implement `Real.fmt StringCvt.EXACT`. So, a "fixed" version of `structure Real64` needs to be exported (rather than exposing the version of `structure Real64` from `$/basis.cm`) and it is simplest to revert back to `structure Real64 = Real` (where `structure Real = FixReal(struct open Pervasive.Real end)`).
|
I have been experimenting with building MLton from scratch using SML/NJ. As of #520 (which fixed #519), the command
make smlnj-mlton
now succeeds, producingbuild/bin/mlton.smlnj
.Unfortunately, however,
mlton.smlnj
crashes due to a problem in SML/NJ's implementation ofReal.fmt
, which raises an exception forEXACT
formatting (link).For example:
And, one consequence of this is that
make bootstrap-smlnj
fails!Some digging
I traced the crash back to
RealX.toString
here:mlton/mlton/atoms/real-x.fun
Lines 88 to 98 in 537750a
Which in turn triggers a call to
Real.fmt StringCvt.EXACT
, here:mlton/lib/mlton/basic/real.sml
Line 61 in 537750a
Workaround
Here's a hack which appears to work:
Discussion
@MatthewFluet curious to get your thoughts on this. Of course, it would be great if SML/NJ didn't have this problem, but alas, it does. And, it would be nice if bootstrapping with SML/NJ worked.
My understanding is that, for any code that contains constants of type
real
, these constants will need to be laid out as a string at some point (either internally for one of the IRs, or physically in the final output code).Using a fixed precision of 30 in the workaround above seems like it would be "good enough". MLKit uses the same hack at the moment (link).
I wonder if it's possible to use this workaround only for
mlton.smlnj
, and continue to useEXACT
formatting for normalmlton
? If so, would you like me to try to implement that?The text was updated successfully, but these errors were encountered: