You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 1359 Reporter: administrator Status: closed Resolution: not a bug Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Stefan Kral
Version: 3.06
OS: SuSE Linux 7.0 (i386)
Submission from: a49.dialin.tuwien.ac.at (192.35.240.59)
Hi,
I have problems mixing sum-types and records.
Having read nowhere that this is illegal, I
assumed that the following should work...
(also, because references are similarly defined)
First try:
stefan@schlaubi:~/ml > ocaml
Objective Caml version 3.06
type tree =
| Empty
| Node of complexnode
and complexnode =
{
mutable pos : int;
s0 : tree;
s1 : tree;
};;
type tree = Empty | Node of complexnode
type complexnode = { mutable pos : int; s0 : tree; s1 : tree; }
Original bug ID: 1359
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Stefan Kral
Version: 3.06
OS: SuSE Linux 7.0 (i386)
Submission from: a49.dialin.tuwien.ac.at (192.35.240.59)
Hi,
I have problems mixing sum-types and records.
Having read nowhere that this is illegal, I
assumed that the following should work...
(also, because references are similarly defined)
First try:
stefan@schlaubi:~/ml > ocaml
Objective Caml version 3.06
type tree =
and complexnode =
{
mutable pos : int;
s0 : tree;
s1 : tree;
};;
type tree = Empty | Node of complexnode
type complexnode = { mutable pos : int; s0 : tree; s1 : tree; }
{ pos = 1, s0 = Empty, s1 = Empty };;
Characters 11-13:
{ pos = 1, s0 = Empty, s1 = Empty };;
^^
Unbound value s0
At first, I thought that this might be related to the mutable field, pos.
So I tried the same with a record-type containing only immutable fields...
stefan@schlaubi:~/ml > ocaml
Objective Caml version 3.06
type tree =
and complexnode =
{
pos : int;
s0 : tree;
s1 : tree;
};;
type tree = Empty | Node of complexnode
type complexnode = { pos : int; s0 : tree; s1 : tree; }
{ pos = 1, s0 = Empty, s1 = Empty };;
Characters 11-13:
{ pos = 1, s0 = Empty, s1 = Empty };;
^^
Unbound value s0
Next, I thought that the mutually recursive definition might pose a problem.
stefan@schlaubi:~/ml > ocaml
Objective Caml version 3.06
type tree =
type tree = Empty | Node of tree * tree
type complexnode =
type complexnode = { mutable pos : int; s0 : tree; s1 : tree; }
{ pos = 1, s0 = Empty, s1 = Empty };;
Characters 11-13:
{ pos = 1, s0 = Empty, s1 = Empty }
^^
Unbound value s0
I tried different names (as a substitute for s0), without success.
First, I thought that the identifier of the second field is always
the culprit.
But then I tried changing the order of fields in the definition
of the record-type...
type tree =
type tree = Empty | Node of tree * tree
type complexnode =
type complexnode = { s0 : tree; mutable pos : int; s1 : tree; }
{ s0 = Empty; pos = 1; s1 = Empty };;
Alas, it seems so work ;-) I can't help but think that the
other definition(s) should have worked just as well...
Regards,
Stefan
The text was updated successfully, but these errors were encountered: