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: 841 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
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.
The text was updated successfully, but these errors were encountered:
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 ;;
let cb1 = new cb ;;
cb1#set_atts [ca1];val cb1 : ('a -> '_b, 'c ca -> '_d as 'c) cb as 'a =
cb1#set_atts [ca1];;
cb1#set_transform (fun x -> x) (fun x -> x);;
It hangs ....
^CInterrupted.
The text was updated successfully, but these errors were encountered: