* [Caml-list] Problem with forall and method
@ 2011-07-26 12:17 Polux Moon
2011-07-26 22:46 ` Jacques Garrigue
0 siblings, 1 reply; 2+ messages in thread
From: Polux Moon @ 2011-07-26 12:17 UTC (permalink / raw)
To: caml-list
[-- Attachment #1.1: Type: text/plain, Size: 726 bytes --]
(Sorry for duplicate mail, I forgot to change the subject in the first one)
Hi,
I have a type error on code similar to :
-----
type 'par t = 'par
let ident v = v
class alias =
object
method alias : 'a . 'a t -> 'a = ident (* type error here *)
end
-----
Which gives :
-----
Error: This expression has type 'a. 'a t -> 'a
but an expression was expected of type 'b. 'b t -> 'b
Type 'a a = 'a is not compatible with type 'b t = 'b
-----
The problem is related to unification of foralls containing named type in a
method.
The compiler accepts equivalent code when not using the named type "t" or
when not using a method (see attached file).
Is it a [known] limitation ? Is there a way to work around it ?
[-- Attachment #1.2: Type: text/html, Size: 943 bytes --]
[-- Attachment #2: forallclass.ml --]
[-- Type: text/x-ocaml, Size: 300 bytes --]
type 'par t = 'par
let ident v = v (* here adding : 'a . 'a a -> 'a changes nothing *)
class alias =
object
method alias : 'a . 'a t -> 'a = ident (* NOT OK *)
end
(* but *)
let alias : 'a . 'a t -> 'a = ident (* OK *)
type r = { alias : 'a . 'a t -> 'a}
let alias = { alias = ident } (* OK *)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] Problem with forall and method
2011-07-26 12:17 [Caml-list] Problem with forall and method Polux Moon
@ 2011-07-26 22:46 ` Jacques Garrigue
0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2011-07-26 22:46 UTC (permalink / raw)
To: Polux Moon; +Cc: caml-list
This is a bug.
Please report to http://caml.inria.fr/mantis
Jacques Garrigue
On 2011/07/26, at 21:17, Polux Moon wrote:
> (Sorry for duplicate mail, I forgot to change the subject in the first one)
>
> Hi,
>
> I have a type error on code similar to :
>
> -----
> type 'par t = 'par
>
> let ident v = v
>
> class alias =
> object
> method alias : 'a . 'a t -> 'a = ident (* type error here *)
> end
> -----
>
> Which gives :
>
> -----
> Error: This expression has type 'a. 'a t -> 'a
> but an expression was expected of type 'b. 'b t -> 'b
> Type 'a a = 'a is not compatible with type 'b t = 'b
> -----
>
> The problem is related to unification of foralls containing named type in a method.
> The compiler accepts equivalent code when not using the named type "t" or when not using a method (see attached file).
>
> Is it a [known] limitation ? Is there a way to work around it ?
>
> <forallclass.ml>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-07-26 22:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-26 12:17 [Caml-list] Problem with forall and method Polux Moon
2011-07-26 22:46 ` Jacques Garrigue
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox