Last active
October 10, 2015 20:17
-
-
Save msullivan/3744805 to your computer and use it in GitHub Desktop.
sml array indexing fail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Running `fail ()` at the repl will cause it to say: | |
unexpected exception (bug?) in SML/NJ: Representation [Representation] *) | |
fun fail () = | |
let fun idx a i = | |
case (Array.sub (a, i)) | |
of NONE => raise Fail "owt" | |
| SOME x => x | |
val a = Array.array (1, SOME (42, 1337)) | |
in idx a 0 end | |
(* Running `thing (fail ())` will print some bogus numbers. | |
* If I had thing *call* fail, then sml/nj crashed while compiling the file?? *) | |
fun thing x = | |
let val (i, j) = x | |
in print (Int.toString i ^ " " ^ Int.toString j ^ "\n") end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment