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

Inconsistent polymorphic method printing #6632

Closed
vicuna opened this issue Oct 27, 2014 · 3 comments
Closed

Inconsistent polymorphic method printing #6632

vicuna opened this issue Oct 27, 2014 · 3 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented Oct 27, 2014

Original bug ID: 6632
Reporter: @lpw25
Assigned to: @lpw25
Status: resolved (set by @lpw25 on 2017-02-27T14:51:13Z)
Resolution: not a bug
Priority: normal
Severity: minor
Target version: undecided
Category: typing

Bug description

This may be the intended behaviour, but it seems a bit strange that polymorphic methods are printed differently depending on whether they are private or not:

# class type t = object method m : 'a . 'a -> 'a end;;
class type t = object method m : 'a -> 'a end

# class type t = object method private m : 'a . 'a -> 'a end;;
class type t = object method private m : 'a. 'a -> 'a end
@vicuna
Copy link
Author

vicuna commented Oct 27, 2014

Comment author: @gasche

To me it's clearly a small bug, but I'm not sure where it comes from (the relevant code in Printtyp doesn't seem to handle both cases differently...).

@vicuna
Copy link
Author

vicuna commented Oct 28, 2014

Comment author: @lpw25

I found it in the code rather than when using the language. There is a match on Fpresent in one of the functions in printtyp.ml, something like method_type (not at my computer so can't check now).

@vicuna
Copy link
Author

vicuna commented Oct 28, 2014

Comment author: @garrigue

This is not a bug; this is intentional.
The idea was to print class types as compactly as possible.
For public methods, all their type variables must appear in the type parameters, so the missing ones are clearly universal variables.
For private methods, this is not always the case.
Here is an example:

class c x = object (self) method private x = x method l = List.length self#x end;;

class c : 'a list -> object method l : t method private x : 'a list end

#show_class_type c;;

class type c = object method l : int method private x : 'a list end

Retrospectively, I'm not so sure hiding universal variables in method types was a very good idea.
But it comes handy for lablgtk for instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants