Skip to content
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

Word.scan #494

Closed
minoki opened this issue May 28, 2023 · 1 comment
Closed

Word.scan #494

minoki opened this issue May 28, 2023 · 1 comment

Comments

@minoki
Copy link

minoki commented May 28, 2023

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, "")
@MatthewFluet
Copy link
Member

Agreed, this is deviating from the SML Basis Library specification. Should be easy enough to fix.

MatthewFluet added a commit to MatthewFluet/mlton that referenced this issue May 29, 2023
Thanks to minoki (arata, mizuki) for the bug report; see
MLton#494.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants