MantisBT - OCaml
View Issue Details
0004824OCaml~DO NOT USE (was: OCaml general)public2009-06-15 17:012010-06-08 10:46
pveber 
garrigue 
normalminoralways
closedfixed 
3.11.0 
3.12.0+dev 
0004824: Narrowing the type of class parameters with module specification
The following definition is rejected :

# module M :
   sig
     class x : int -> object method m : int end
  end
=
struct
  class x _ = object
    method m = 42
  end
end;;
Error: Signature mismatch:
       Modules do not match:
         sig class x : 'a -> object method m : int end end
       is not included in
         sig class x : int -> object method m : int end end
       Class declarations do not match:
         class x : 'a -> object method m : int end
       does not match
         class x : int -> object method m : int end
       One parameter has type 'a but is expected to have type int

Is there a good reason for this ?

Philippe.
No tags attached.
Issue History
2009-06-15 17:01pveberNew Issue
2009-06-16 15:31pveberNote Added: 0004997
2009-06-22 17:59doligezCategoryOCaml documentation => OCaml general
2010-04-30 06:50garrigueStatusnew => assigned
2010-04-30 06:50garrigueAssigned To => garrigue
2010-06-08 10:40garrigueNote Added: 0005549
2010-06-08 10:46garrigueNote Added: 0005550
2010-06-08 10:46garrigueStatusassigned => closed
2010-06-08 10:46garrigueResolutionopen => fixed
2010-06-08 10:46garrigueFixed in Version => 3.12.0+dev
2017-02-23 16:36doligezCategoryOCaml general => -OCaml general
2017-03-03 17:55doligezCategory-OCaml general => -(deprecated) general
2017-03-03 18:01doligezCategory-(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04doligezCategory~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)

Notes
(0004997)
pveber   
2009-06-16 15:31   
Sorry, I wrongly labeled this report's category, which should be "Ocaml general".
Maybe it should also be labeled as feature, rather than bug ...
(0005549)
garrigue   
2010-06-08 10:40   
While trying to fix this problem, I discovered a gaping hole in the type system, at least since ocaml 2.00:

module M : sig class c : 'a -> object val x : 'b end end =
  struct class c x = object val x = x end end

class c (x : int) = object inherit M.c x method x : bool = x end

let r = (new c 2)#x;;
(0005550)
garrigue   
2010-06-08 10:46   
Allow narrowing of class parameters, and close the unsoundness bug mentioned as note.
Fixed in version/3.12 revision 10541.

Note that the closing of this unsoundness is going to break many programs,
including lablgtk.