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

ocamldep is broken (especially when you use first class module) #5738

Closed
vicuna opened this issue Aug 25, 2012 · 6 comments
Closed

ocamldep is broken (especially when you use first class module) #5738

vicuna opened this issue Aug 25, 2012 · 6 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented Aug 25, 2012

Original bug ID: 5738
Reporter: @bobzhang
Assigned to: @garrigue
Status: closed (set by @garrigue on 2012-08-25T11:37:33Z)
Resolution: fixed
Priority: normal
Severity: major
Fixed in version: 4.00.1+dev
Category: tools (ocaml{lex,yacc,dep,debug,...})

Bug description

let f (module A : B) =
A.v ;;

will generate dependency on module A, actually not. If you happens to have a file A.ml(very likely), it will tries to compile module A. Reading the mantis quite a bit, I found this is a long existing problem. Things become worse if you use first class modules a lot. Is there solutions to work around such problem?
I set the severity to be major, because it nearly breaks all my existing repos when I switched to first class modules.

Many thanks

File attachments

@vicuna
Copy link
Author

vicuna commented Aug 25, 2012

Comment author: @garrigue

Fixed in trunk and 4.00, revisions 12878 and 12879.

@vicuna
Copy link
Author

vicuna commented Aug 25, 2012

Comment author: @lefessan

Are you sure it is fixed ? Compiling latest SVN does not solve the problem for me:

$ touch a.ml
$ touch d.ml
$ cat > c.ml
module type B = sig val x : int end
let f (module A : B) = A.x
module X = struct let x = 4 end;;
let (module D : B) = (module X : B ) in D.x;;
$ ocamlc -c c.ml
(works, no dependency on a.ml and d.ml)
$ ocamldep c.ml
c.cmo : d.cmo a.cmo
c.cmx : d.cmx a.cmx
(dependencies are still there)

@vicuna
Copy link
Author

vicuna commented Aug 25, 2012

Comment author: @lefessan

Jacques, could you check if it is fixed, and maybe try my patch that I was about to submit (attached to the bug report).

@vicuna
Copy link
Author

vicuna commented Aug 25, 2012

Comment author: @garrigue

Sorry, I got confused by Ppat_type :-)
Fixed properly now, almost using Fabrice's code.

@vicuna
Copy link
Author

vicuna commented Aug 25, 2012

Comment author: @lefessan

and add_bindings recf bv pel =
let bv' = List.fold_left (fun bv (p, _) -> add_pattern bv p) bv pel in

let bv = if recf = Recursive then bv else bv' in
List.iter (fun (_, e) -> add_expr bv e) pel;
bv'

Isn't it

let bv = if recf = Recursive then bv' else bv in

instead ?

@vicuna
Copy link
Author

vicuna commented Aug 25, 2012

Comment author: @garrigue

Sorry, I'm too sleepy today.
I should have reused your code for this part.

By the way, the use of a mutable variable for patterns is intentional:
the module only comes in scope after processing the whole pattern.

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