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

typing error instead of scoping error #2550

Closed
vicuna opened this issue May 5, 2004 · 4 comments
Closed

typing error instead of scoping error #2550

vicuna opened this issue May 5, 2004 · 4 comments

Comments

@vicuna
Copy link

vicuna commented May 5, 2004

Original bug ID: 2550
Reporter: administrator
Status: closed (set by @damiendoligez on 2012-01-27T21:12:28Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 3.09.0
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Daniel Weil
Version: 3.07
OS: win32
Submission from: 81.80.88.226 (81.80.88.226)

Suppose you have the file "toto.ml" containing the data:
type 'a t = A of 'a | B
let f () = Toto.B

and the file "toto.mli" containing the data:
type 'a t = A of 'a | B
val f : unit -> 'a t

When I compile first the .ml file (with "ocaml -c toto.ml"), I get a scoping
error which is good.

But when i compile first the .mli and the the .ml (ocamlc -c toto.mli; ocamlc -c
toto.ml), I have a surprising typing error :

The implementation toto.ml does not match the interface toto.cmi:
Values do not match:
val f : unit -> 'a Toto.t
is not included in
val f : unit -> 'a t

I looks like a bug with separate compilation because it does not happen if i put
in a single file the module toto constrained by its signature.

@vicuna
Copy link
Author

vicuna commented May 28, 2004

Comment author: administrator

Suppose you have the file "toto.ml" containing the data:
type 'a t = A of 'a | B
let f () = Toto.B

and the file "toto.mli" containing the data:
type 'a t = A of 'a | B
val f : unit -> 'a t

When I compile first the .ml file (with "ocaml -c toto.ml"), I get a scoping
error which is good.

But when i compile first the .mli and the the .ml (ocamlc -c toto.mli; ocamlc
-c
toto.ml), I have a surprising typing error :

The implementation toto.ml does not match the interface toto.cmi:
Values do not match:
val f : unit -> 'a Toto.t
is not included in
val f : unit -> 'a t

This could be a FAQ: using the module name Toto inside a file toto.ml has no
well-defined meaning, so you shouldn't do that.

But maybe we could add a special error message for that?
(for instance, adding a check in Env.find_pers_structure; but we need to know
which file we are compiling...)

Jacques

@vicuna
Copy link
Author

vicuna commented May 28, 2004

Comment author: administrator

Improve the error message? (JG)

@vicuna
Copy link
Author

vicuna commented Jun 9, 2004

Comment author: administrator

For me, it looks more like a bug of the CAML compiler :

The compiler should
- first infer the signature of the ml file (no matter if the .cmi
exists or not) and fail if any scoping/typing error is encountered
- and then only compare this signature to the .cmi file.

Daniel

                  Jacques Garrigue                                                                                                   
                  <caml-bugs@pauilla        Pour :    daniel_weil@ds-fr.com                                                          
                  c.inria.fr>               cc :      caml@pauillac.inria.fr                                                         
                                            Objet :   Re: typing error instead of scoping error (#2550)                            
                  05/28/2004 05:14                                                                                                   
                  AM                                                                                                                 

Suppose you have the file "toto.ml" containing the data:
type 'a t = A of 'a | B
let f () = Toto.B

and the file "toto.mli" containing the data:
type 'a t = A of 'a | B
val f : unit -> 'a t

When I compile first the .ml file (with "ocaml -c toto.ml"), I get a
scoping
error which is good.

But when i compile first the .mli and the the .ml (ocamlc -c toto.mli;
ocamlc
-c
toto.ml), I have a surprising typing error :

The implementation toto.ml does not match the interface toto.cmi:
Values do not match:
val f : unit -> 'a Toto.t
is not included in
val f : unit -> 'a t

This could be a FAQ: using the module name Toto inside a file toto.ml has
no
well-defined meaning, so you shouldn't do that.

But maybe we could add a special error message for that?
(for instance, adding a check in Env.find_pers_structure; but we need to
know
which file we are compiling...)

Jacques

@vicuna
Copy link
Author

vicuna commented Jan 27, 2012

Comment author: @damiendoligez

This was fixed at some point between 3.08.0 and 3.09.0.
I now get the same (correct) error message in both cases.

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

1 participant