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

Narrowing the type of class parameters with module specification #4824

Closed
vicuna opened this issue Jun 15, 2009 · 3 comments
Closed

Narrowing the type of class parameters with module specification #4824

vicuna opened this issue Jun 15, 2009 · 3 comments
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Jun 15, 2009

Original bug ID: 4824
Reporter: pveber
Assigned to: @garrigue
Status: closed (set by @garrigue on 2010-06-08T08:46:06Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.11.0
Fixed in version: 3.12.0+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

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.

@vicuna
Copy link
Author

vicuna commented Jun 16, 2009

Comment author: pveber

Sorry, I wrongly labeled this report's category, which should be "Ocaml general".
Maybe it should also be labeled as feature, rather than bug ...

@vicuna
Copy link
Author

vicuna commented Jun 8, 2010

Comment author: @garrigue

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;;

@vicuna
Copy link
Author

vicuna commented Jun 8, 2010

Comment author: @garrigue

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.

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

2 participants