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: 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
The text was updated successfully, but these errors were encountered:
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).
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.
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:
The text was updated successfully, but these errors were encountered: