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: 3601 Reporter: administrator Assigned to:@garrigue Status: closed (set by @garrigue on 2010-04-30T06:28:04Z) Resolution: fixed Priority: normal Severity: feature Fixed in version: 3.12.0+dev Category: ~DO NOT USE (was: OCaml general)
Mutually recursive data type definitions, written using "type ... and ...",
are not commutative, even though one might expect them to be. This is
illustrated by the following two code snippets.
Snippet 1:
type t = { foo: t} and u = { foo: u };;
type t = { foo : t; }
and u = { foo : u; }
fun x -> x.foo;;
: t -> t =
Snippet 2:
type u = { foo: u } and t = { foo: t };;
type u = { foo : u; }
and t = { foo : t; }
fun x -> x.foo;;
: u -> u =
Suggested solution: detect that a record label is being defined twice
in this mutually recursive definition and reject the program. Do the
same for data constructors.
Note: this is not a theoretical example! I have actually written code
like this and got a type error much later in the program.
The text was updated successfully, but these errors were encountered:
Added a check for duplicates in revision 10331.
This is a hard error.
One might prefer a warning, but currently there is no way to use such duplicates.
Original bug ID: 3601
Reporter: administrator
Assigned to: @garrigue
Status: closed (set by @garrigue on 2010-04-30T06:28:04Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 3.12.0+dev
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Francois Pottier
Version: 3.08+alpha1 (2004-07-03)
OS: RedHat Linux 8
Submission from: madiran.inria.fr (128.93.8.77)
Mutually recursive data type definitions, written using "type ... and ...",
are not commutative, even though one might expect them to be. This is
illustrated by the following two code snippets.
Snippet 1:
type t = { foo: t} and u = { foo: u };;
type t = { foo : t; }
and u = { foo : u; }
fun x -> x.foo;;
Snippet 2:
type u = { foo: u } and t = { foo: t };;
type u = { foo : u; }
and t = { foo : t; }
fun x -> x.foo;;
Suggested solution: detect that a record label is being defined twice
in this mutually recursive definition and reject the program. Do the
same for data constructors.
Note: this is not a theoretical example! I have actually written code
like this and got a type error much later in the program.
The text was updated successfully, but these errors were encountered: