Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with parametric classes #3176

Closed
vicuna opened this issue Jan 28, 2002 · 2 comments
Closed

Bug with parametric classes #3176

vicuna opened this issue Jan 28, 2002 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jan 28, 2002

Original bug ID: 841
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Frederic Tronel
Version: 3.04
OS: solaris
Submission from: cime.inrialpes.fr (194.199.23.76)

With these classes definitions:

exception E
class ['a] ca =
object (this)
val mutable into = ([] : 'a list)
method get_into =
match into with
[] -> raise E
|[x] -> x
|_ -> raise E
method set_into x = into <- [x]
method set_transform = this#set_into
method transform =
this#get_into this
end
and ['a,'b] cb =
object (this)
val mutable into = ([] : 'a list)
method get_into =
match into with
[] -> raise E
|[x] -> x
|_ -> raise E
method set_into x = into <- [x]
val mutable atts = ([] : 'b ca list)
method get_atts = atts
method set_atts x = atts <- x
method set_transform a b =
this#set_into a ;
List.iter (fun x -> x#set_transform b) atts
method transform =
let cb = this#get_into this in
let ca = List.fold_left ( fun a b -> [b#transform]@A ) [] atts in
(cb,ca)
end

Using the compiler:

let _ =
let ca1 = new ca in
let cb1 = new cb in
cb1#set_atts [ca1];
cb1#set_transform (fun x -> x) (fun x -> x);
cb1#transform ; cb1#transform ;
Printf.printf "Fini \n"

cime:2644 ocamlc -i -o bug bug.ml
File "bug.ml", line 41, characters 2-15:
Warning: this expression should have type unit.
File "bug.ml", line 41, characters 19-32:
Warning: this expression should have type unit.
exception E
class ['a] ca :
object ('b)
constraint 'a = 'b -> 'c
val mutable into : 'a list
method get_into : 'a
method set_into : 'a -> unit
method set_transform : 'a -> unit
method transform : 'c
end
class ['a, 'b] cb :
object ('c)
constraint 'a = 'c -> 'd
constraint 'b = 'b ca -> 'e
val mutable atts : 'b ca list
val mutable into : 'a list
method get_atts : 'b ca list
method get_into : 'a
method set_atts : 'b ca list -> unit
method set_into : 'a -> unit
method set_transform : 'a -> 'b -> unit
method transform : 'd * 'e list
end
cime:2645 ./bug
Fini
cime:2646

In the interpreter:

let ca1 = new ca ;;

  • : unit = ()

let cb1 = new cb ;;

cb1#set_atts [ca1];val cb1 : ('a -> '_b, 'c ca -> '_d as 'c) cb as 'a =

cb1#set_atts [ca1];;

  • : unit = ()

cb1#set_transform (fun x -> x) (fun x -> x);;

It hangs ....

^CInterrupted.

@vicuna
Copy link
Author

vicuna commented Jan 29, 2002

Comment author: administrator

Full_Name: Frederic Tronel
Version: 3.04

With these classes definitions:
...
In the interpreter:

cb1#set_transform (fun x -> x) (fun x -> x);;

It hangs ....

Are you sure this is enough to trigger the bug ?
I couldn't reproduce it using the same ocaml 3.04 on Solaris.

Jacques Garrigue

@vicuna
Copy link
Author

vicuna commented Feb 1, 2002

Comment author: administrator

Fixed by Jerome and Jacques (2002-02-01).

@vicuna vicuna closed this as completed Feb 1, 2002
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant