<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/d6c58cb6bc1c6fb69e2a493d4661fb64"
  from="John Prevost &lt;j.prevost@c...&gt;"
  author="John Prevost"
  date="2002-07-30T07:39:19"
  subject="[Caml-list] Serious typechecking error involving new polymorphism (crash)"
  prev="2002/07/3f199bf0a914676a5b41fbca1690aa6f"
  next="2002/07/b497de8320fda3100426c8f53eecb197"
  prev-in-thread="2002/07/3f199bf0a914676a5b41fbca1690aa6f"
  next-in-thread="2002/07/343d65e7899036954a2f9d55ce4afb9d"
  prev-thread="2002/07/39e30771ef4adfd2f12faaf023bfdac5"
  next-thread="2002/07/ff7adba2f7751b11a6ba288c8fc0167a"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] OCaml 3.05 released">
<msg 
  url="2002/07/e279fbfc81d25f8b7b40690d1165d72d"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-29T12:45:29"
  subject="[Caml-list] OCaml 3.05 released">
<msg 
  url="2002/07/b6032d864b192b947849b9fc6bd7755e"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2002-07-29T14:36:37"
  subject="Re: [Caml-list] OCaml 3.05 released">
</msg>
<msg 
  url="2002/07/afd92811daf13a07857d793b1331ba9e"
  from="Shawn Wagner &lt;shawnw@s...&gt;"
  author="Shawn Wagner"
  date="2002-07-30T00:41:47"
  subject="Re: [Caml-list] OCaml 3.05 released">
</msg>
<msg 
  url="2002/07/0efd71474f4d41a39e4250aeddcf08e5"
  from="Scott J. &lt;jscott@p...&gt;"
  author="Scott J."
  date="2002-07-30T03:50:07"
  subject="Re: [Caml-list] OCaml 3.05 released">
<msg 
  url="2002/08/df90b1f50be1a11118e0740523aa551c"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2002-08-02T05:32:07"
  subject="Re: [Caml-list] OCaml 3.05 released">
<msg 
  url="2002/08/db899ec4bb5226b7562107f232561f89"
  from="tim@f..."
  author="tim@f..."
  date="2002-08-02T17:41:42"
  subject="Re: [Caml-list] OCaml 3.05 released">
</msg>
</msg>
<msg 
  url="2002/07/3f199bf0a914676a5b41fbca1690aa6f"
  from="John Prevost &lt;j.prevost@c...&gt;"
  author="John Prevost"
  date="2002-07-30T07:27:55"
  subject="Re: [Caml-list] OCaml 3.05 released">
</msg>
<msg 
  url="2002/07/d6c58cb6bc1c6fb69e2a493d4661fb64"
  from="John Prevost &lt;j.prevost@c...&gt;"
  author="John Prevost"
  date="2002-07-30T07:39:19"
  subject="[Caml-list] Serious typechecking error involving new polymorphism (crash)">
<msg 
  url="2002/07/343d65e7899036954a2f9d55ce4afb9d"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-30T07:58:47"
  subject="Re: [Caml-list] Serious typechecking error involving new polymorphism (crash)">
<msg 
  url="2002/07/36d92762dd1d6949dd33b7393d6c53fc"
  from="John Prevost &lt;j.prevost@c...&gt;"
  author="John Prevost"
  date="2002-07-30T08:15:36"
  subject="Re: [Caml-list] Serious typechecking error involving new polymorphism (crash)">
<msg 
  url="2002/07/90e5f432d519e9e76f617660f10c0efa"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-30T08:48:01"
  subject="Re: [Caml-list] Serious typechecking error involving new polymorphism (crash)">
</msg>
</msg>
<msg 
  url="2002/07/8085b2926393438ac0fa119812ee60f2"
  from="Sven LUTHER &lt;luther@d...&gt;"
  author="Sven LUTHER"
  date="2002-07-30T08:34:21"
  subject="Re: [Caml-list] Serious typechecking error involving new polymorphism (crash)">
<msg 
  url="2002/07/1c4970cfde7596bd9b15e0902376769d"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-30T14:11:34"
  subject="Re: [Caml-list] bug-fix branches">
<msg 
  url="2002/08/ba82a5fb43839056c5e388becc2deb61"
  from="root &lt;root@i...&gt;"
  author="root"
  date="2002-08-01T09:54:12"
  subject="[Caml-list] 3.05 and future 3.06 binary compatibility ?">
<msg 
  url="2002/08/2c4fff8dccd93507970c04eca009cfdb"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-08-01T12:09:41"
  subject="[Caml-list] Re: 3.05 and future 3.06 binary compatibility ?">
<msg 
  url="2002/08/6e264e12e92f890051ea1175f97bbee3"
  from="Sven LUTHER &lt;luther@d...&gt;"
  author="Sven LUTHER"
  date="2002-08-01T16:02:43"
  subject="[Caml-list] Re: 3.05 and future 3.06 binary compatibility ?">
</msg>
<msg 
  url="2002/08/df67723af0add90a69999ff263607208"
  from="Sven LUTHER &lt;luther@d...&gt;"
  author="Sven LUTHER"
  date="2002-08-08T08:33:22"
  subject="[Caml-list] Re: 3.05 and future 3.06 binary compatibility ?">
<msg 
  url="2002/08/41914487b5180ba736af8cb0e967f3a2"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-08-10T10:12:42"
  subject="[Caml-list] Re: 3.05 and future 3.06 binary compatibility ?">
<msg 
  url="2002/08/e865d7ffc0f6cfcb7d96317b3b113b04"
  from="Sven LUTHER &lt;luther@d...&gt;"
  author="Sven LUTHER"
  date="2002-08-10T10:18:13"
  subject="[Caml-list] Re: 3.05 and future 3.06 binary compatibility ?">
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/4473ba7d51d430e8719525d0744d943c"
  from="Sven LUTHER &lt;luther@d...&gt;"
  author="Sven LUTHER"
  date="2002-07-30T16:37:24"
  subject="Re: [Caml-list] bug-fix branches">
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/b497de8320fda3100426c8f53eecb197"
  from="Dmitry Bely &lt;dbely@m...&gt;"
  author="Dmitry Bely"
  date="2002-07-30T07:55:28"
  subject="Re: [Caml-list] OCaml 3.05 released">
<msg 
  url="2002/07/3f28649c188a4e7ae0bf9965ec6c2967"
  from="Scott J. &lt;jscott@p...&gt;"
  author="Scott J."
  date="2002-07-30T15:01:31"
  subject="Re: [Caml-list] OCaml 3.05 released">
<msg 
  url="2002/07/2a2bcb8c76923b4de71a17c6b47bc869"
  from="Dmitry Bely &lt;dbely@m...&gt;"
  author="Dmitry Bely"
  date="2002-07-30T15:15:16"
  subject="Re: [Caml-list] OCaml 3.05 released">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/c2213777c53be1e9911cdba2fdcaabd7"
  from="Yaron M. Minsky &lt;yminsky@C...&gt;"
  author="Yaron M. Minsky"
  date="2002-07-30T11:49:06"
  subject="Re: [Caml-list] OCaml 3.05 released">
</msg>
<msg 
  url="2002/07/1202a549e6e87be5cee18a8b76937e94"
  from="Christophe Raffalli &lt;raffalli@u...&gt;"
  author="Christophe Raffalli"
  date="2002-07-30T22:15:10"
  subject="[Caml-list] Record with one non mutable filed">
</msg>
</msg>
</thread>

<contents>
I've discovered a fairly serious typechecking bug in 3.05.  I'm
reporting it on the webpage, but also want to mention it here so that
people are aware.

You can do the following:

# type bad = { x : 'a . 'a option ref };;
type bad = { x : 'a. 'a option ref; } 
# let bv = { x = ref None };;
val bv : bad = {x = {contents = None}}
# bv.x := Some 5;;
- : unit = ()
# let extra_bad = !(bv.x);;
val extra_bad : '_a option = Some &lt;poly&gt;
# f extra_bad;;

***CRASH***

It looks like mutable fields are handled correctly and catch that the
value is not, in fact, general enough.  But when the mutable field is
part of the value (in this case, part of the ref), the check is not
done.


To be safe, I recommend being very wary of using field types like:

'a . &lt;type expression involving 'a&gt;

In which values of the type involve mutable portions of type 'a.  As
long as any mutable portion is not also polymorphic, things are fine.

Mutable fields are fine as well, as long as you are careful as
described above.

As an example, Using

mutable x : 'a . 'a option

instead of

x : 'a . 'a option ref

in the above example prevents any poorly typed expressions from
appearing.  No value may be put in the "good" example except None,
since None is the only fully polymorphic option value.

John.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

