MLton's Word.scan seems to be buggy when 0 is followed by w/x but not by more digits.
Example:
fun testScan scan s = case scan Substring.getc (Substring.full s) of
NONE => print "NONE\n"
| SOME (result, rest) => print ("SOME (0w" ^ Word.fmt StringCvt.DEC result ^ ", \"" ^ Substring.string rest ^ "\")\n")
val () = List.app (testScan (Word.scan StringCvt.BIN))
["0", "0w", "0wx", "0x"];
val () = List.app (testScan (Word.scan StringCvt.OCT))
["0", "0w", "0wx", "0x"];
val () = List.app (testScan (Word.scan StringCvt.DEC))
["0", "0w", "0wx", "0x"];
val () = List.app (testScan (Word.scan StringCvt.HEX))
["0", "0w", "0wx", "0x"];
Expected output:
SOME (0w0, "")
SOME (0w0, "w")
SOME (0w0, "wx")
SOME (0w0, "x")
SOME (0w0, "")
SOME (0w0, "w")
SOME (0w0, "wx")
SOME (0w0, "x")
SOME (0w0, "")
SOME (0w0, "w")
SOME (0w0, "wx")
SOME (0w0, "x")
SOME (0w0, "")
SOME (0w0, "w")
SOME (0w0, "wx")
SOME (0w0, "x")
MLton's output:
SOME (0w0, "")
SOME (0w0, "")
SOME (0w0, "x")
NONE
SOME (0w0, "")
SOME (0w0, "")
SOME (0w0, "x")
NONE
SOME (0w0, "")
SOME (0w0, "")
SOME (0w0, "x")
NONE
SOME (0w0, "")
SOME (0w0, "w")
SOME (0w0, "")
SOME (0w0, "")
MLton's
Word.scan
seems to be buggy when0
is followed byw
/x
but not by more digits.Example:
Expected output:
MLton's output: