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

ocamlbuild foo.inferred.ml does yield a WRONG signature and ocamlc complains... #7295

Closed
vicuna opened this issue Jul 20, 2016 · 3 comments
Closed
Assignees

Comments

@vicuna
Copy link

vicuna commented Jul 20, 2016

Original bug ID: 7295
Reporter: tormen
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2017-09-24T15:33:13Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.3
Fixed in version: later
Category: -for ocamlbuild use https://github.com/ocaml/ocamlbuild/issues

Bug description

NOT SURE IF THIS IS AN OCAMLBUILD or ocamlc problem... as I am quite new to the ocaml ecosystem, I let you figure that out if it's okey... (but I will hungrily consume any explanation about what category this bug should or should not be assigned to :)).

inferred.mli tells me
val not_found : (unit -> 'a) -> bool and
when I compile it complains about
val not_found : (unit -> unit) -> bool
not matching
val not_found : (unit -> 'a) -> bool

Steps to reproduce

1.) foo.ml:
let not_found f = try f (); false with Not_found -> true

2.) ocamlbuild -use-ocamlfind -pkg core -tag "ppx(ppx-jane -as-ppx)" -tag thread -tag debug -tag bin_annot -tag short_paths -tag safe_string -cflags "-w +27@0..26-4@28..99-33-40-41-42-43-34-44" -cflags -strict-sequence -cflags -safe-string -verbose 0 -Is -use-ocamlfind -pkgs pgocaml,pgocaml.syntax,deriving,deriving-yojson.syntax,deriving-yojson,calendar -syntax camlp4o -tag thread foo.inferred.mli

3.) cat _build/foo.inferred.mli:
val not_found : (unit -> 'a) -> bool

4.) cp _build/foo.inferred.mli foo.mli

5.) ocamlbuild -use-ocamlfind -pkg core -tag "ppx(ppx-jane -as-ppx)" -tag thread -tag debug -tag bin_annot -tag short_paths -tag safe_string -cflags "-w +27@0..26-4@28..99-33-40-41-42-43-34-44" -cflags -strict-sequence -cflags -safe-string -verbose 0 -Is -use-ocamlfind -pkgs pgocaml,pgocaml.syntax,deriving,deriving-yojson.syntax,deriving-yojson,calendar -syntax camlp4o -tag thread foo.native

Should yield:
File "foo.ml", line 1:
Error: The implementation foo.ml does not match the interface foo.cmi:
Values do not match:
val not_found : (unit -> unit) -> bool
is not included in
val not_found : (unit -> 'a) -> bool
File "foo.ml", line 2, characters 4-13: Actual declaration
Command exited with code 2.

Additional information

So IMHO (also myself looking at the code) the _build/foo.inferred.mli should have contained:
val not_found : (unit -> unit) -> bool

(because "f (); false" means f () needs to evaluate to unit (because of the following ";" and it certainly gets a unit input, so (unit -> unit) is correct.

@vicuna
Copy link
Author

vicuna commented Jul 20, 2016

Comment author: @yallop

In summary: ocamlbuild doesn't pass -strict-sequence through to 'ocamlc -i', so the inferred type used to generate the interface is more general than the type inferred when compiling the implementation.

@vicuna
Copy link
Author

vicuna commented Jul 20, 2016

Comment author: tormen

Similar problem happens, when you change "f ()" to (Lazy.force f) in the above foo.ml

@vicuna
Copy link
Author

vicuna commented Jul 20, 2016

Comment author: @gasche

This is indeed an ocamlbuild issue and I fixed it in

ocaml/ocamlbuild@3d8e638

It will be available in the next release of ocamlbuild.

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

2 participants