* [Caml-list] Change in typing between OCaml 4.01.0 and 4.02.2...
@ 2015-06-26 18:07 Stéphane Glondu
2015-06-26 19:15 ` Jeremy Yallop
0 siblings, 1 reply; 4+ messages in thread
From: Stéphane Glondu @ 2015-06-26 18:07 UTC (permalink / raw)
To: caml users; +Cc: Debian Ocaml Maint ML, 790062
Hello,
I am debugging why monotone-viz doesn't compile with OCaml 4.02.2. I
have reduced the problem to the following:
$ cat query.mli
val make : #App.t -> unit
$ cat app.mli
class type status =
object
method pop : unit -> unit
end
class type t =
object
method query : status -> unit
end
val make : unit -> t
$ cat app.ml
class type status =
object
method pop : unit -> unit
end
class type t =
object
method query : status -> unit
end
class ctrl : t =
object (self)
method query status =
Query.make self;
status#pop ()
end
let make () =
new ctrl
$ ocamlc -c app.mli
$ ocamlc -c query.mli
$ ocamlc -c app.ml
With OCaml 4.02.2, I get the following error message:
File "app.ml", line 15, characters 6-12:
Error: This expression has type App.status
It has no method pop
which looks wrong. With OCaml 4.01.0, there is no error.
Does anyone understand what is going on?
Cheers,
--
Stéphane
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Change in typing between OCaml 4.01.0 and 4.02.2...
2015-06-26 18:07 [Caml-list] Change in typing between OCaml 4.01.0 and 4.02.2 Stéphane Glondu
@ 2015-06-26 19:15 ` Jeremy Yallop
2015-06-28 9:44 ` Jacques Garrigue
0 siblings, 1 reply; 4+ messages in thread
From: Jeremy Yallop @ 2015-06-26 19:15 UTC (permalink / raw)
To: Stéphane Glondu; +Cc: caml users, Debian Ocaml Maint ML, 790062
On 26 June 2015 at 19:07, Stéphane Glondu <steph@glondu.net> wrote:
> $ cat query.mli
> val make : #App.t -> unit
> $ cat app.ml
[...]
> Query.make self;
[...]
> With OCaml 4.02.2, I get the following error message:
>
> File "app.ml", line 15, characters 6-12:
> Error: This expression has type App.status
> It has no method pop
>
> which looks wrong. With OCaml 4.01.0, there is no error.
>
> Does anyone understand what is going on?
I think this is a result of tighter checks against self-references
when compiling modules:
http://caml.inria.fr/mantis/view.php?id=6886
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Change in typing between OCaml 4.01.0 and 4.02.2...
2015-06-26 19:15 ` Jeremy Yallop
@ 2015-06-28 9:44 ` Jacques Garrigue
2015-06-28 17:04 ` Stéphane Glondu
0 siblings, 1 reply; 4+ messages in thread
From: Jacques Garrigue @ 2015-06-28 9:44 UTC (permalink / raw)
To: Stéphane Glondu, Jeremy Yallop; +Cc: OCaML List Mailing
On 2015/06/27 04:15, Jeremy Yallop wrote:
>
> On 26 June 2015 at 19:07, Stéphane Glondu <steph@glondu.net> wrote:
>> $ cat query.mli
>> val make : #App.t -> unit
>
>> $ cat app.ml
> [...]
>> Query.make self;
> [...]
>> With OCaml 4.02.2, I get the following error message:
>>
>> File "app.ml", line 15, characters 6-12:
>> Error: This expression has type App.status
>> It has no method pop
>>
>> which looks wrong. With OCaml 4.01.0, there is no error.
>>
>> Does anyone understand what is going on?
>
> I think this is a result of tighter checks against self-references
> when compiling modules:
>
> http://caml.inria.fr/mantis/view.php?id=6886
Indeed, this seems to be the direct cause.
Note that the behavior of referring to oneself through an external
name was never properly defined (most often it would already fail
and even when succeeding it was referring to another definition).
The correct way to do this is either to duplicate the definition of
status in both app and query (removing the cyclic dependency),
or to define it in another file, which can be correctly referred to by both.
Yet, we should probably try to improve the error message,
which is indeed confusing. Not so easy, because this kind of
self-reference can be detected at very unexpected timings.
Can you add a comment to the above bug report?
Jacques Garrigue
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Change in typing between OCaml 4.01.0 and 4.02.2...
2015-06-28 9:44 ` Jacques Garrigue
@ 2015-06-28 17:04 ` Stéphane Glondu
0 siblings, 0 replies; 4+ messages in thread
From: Stéphane Glondu @ 2015-06-28 17:04 UTC (permalink / raw)
To: Jacques Garrigue; +Cc: OCaML List Mailing, 790062
Le 28/06/2015 11:44, Jacques Garrigue a écrit :
>> I think this is a result of tighter checks against self-references
>> when compiling modules:
>>
>> http://caml.inria.fr/mantis/view.php?id=6886
>
> Indeed, this seems to be the direct cause.
> Note that the behavior of referring to oneself through an external
> name was never properly defined (most often it would already fail
> and even when succeeding it was referring to another definition).
> The correct way to do this is either to duplicate the definition of
> status in both app and query (removing the cyclic dependency),
> or to define it in another file, which can be correctly referred to by both.
I did the latter in a patch that fixes the compilation of monotone-viz:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=790062#22
> Yet, we should probably try to improve the error message,
> which is indeed confusing. Not so easy, because this kind of
> self-reference can be detected at very unexpected timings.
> Can you add a comment to the above bug report?
Done.
Cheers,
--
Stéphane
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-06-28 17:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-26 18:07 [Caml-list] Change in typing between OCaml 4.01.0 and 4.02.2 Stéphane Glondu
2015-06-26 19:15 ` Jeremy Yallop
2015-06-28 9:44 ` Jacques Garrigue
2015-06-28 17:04 ` Stéphane Glondu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox