From: Nick B. <ni...@mi...> - 2004-04-11 18:46:10
|
SML.NET rejects it, though the error message leaves room for improvement!=20 match error: f =20 type specified: 'a option->'a option =20 type inferred: 'a option->'a option Nick -----Original Message----- From: sml...@li... [mailto:sml...@li...] On Behalf Of Stephen Weeks Sent: 09 April 2004 19:38 To: sml...@li... Subject: [Sml-implementers] type-checking bug in several implementations The following program is incorrectly handled by Hamlet, MLton, the ML Kit, and Moscow ML. It should be rejected as type incorrect. Hamlet and Moscow ML compile the program, but encounter a run time error (a seg fault in the case of Moscow ML). MLton and the ML Kit report internal errors at compile time. I suspect all four suffer from the same defect in the type checker, which is too lax and concludes that a monotype containing an unspecified type generalizes a type scheme. ------------------------------------------------------------ structure S: sig val f: 'a option -> 'a option end =3D struct val make: unit -> 'a option -> 'a option =3D fn () =3D> let val r: 'a option ref =3D ref NONE in fn z =3D> (!r before (r :=3D z)) end val f =3D make () end val _ =3D S.f (SOME 13) val _ =3D case S.f (SOME (fn z =3D> z)) of NONE =3D> 15 | SOME f =3D> f 17 ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=3D1470&alloc_id=3D3638&op=3Dcli= ck _______________________________________________ Sml-implementers mailing list Sml...@li... https://lists.sourceforge.net/lists/listinfo/sml-implementers |