[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | David Baelde <david.baelde@g...> |
| Subject: | Re: [Caml-list] bug in object type inference ? |
Hi Romain, This is not a bug, but just a limitation of type inference on labels -- it is independent from OO. If a type is unknown and is used for a labelled application, the parameter will be supposed to be mandatory. I guess inference goes too wild without that restriction -- because with types where the optionality is unknown, it is also unknown when an application is total. A simpler example of that: # let g f a = f ~a () ;; val g : (a:'a -> unit -> 'b) -> 'a -> 'b = <fun> The type of f is infered with a mandatory param labelled a. # let f ?a b = b ;; val f : ?a:'a -> 'b -> 'b = <fun> # g f ;; This expression has type ?a:'a -> 'b -> 'b but is here used with type a:'c -> unit -> 'd This would work with an annotation in the declaration of g: # let g (f : ?a:'a -> unit -> 'b) a = f ~a () ;; val g : (?a:'a -> unit -> 'b) -> 'a -> 'b = <fun> -- David