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 -map options interpreted "backwards" #7249
Comments
Comment author: antron I'm not as sure of this as open. There is a sensible interpretation of -map in the "backwards" order, because the alias structure is being built "up", whereas open drills "down". But, it goes against the correct order of open, and is somewhat surprising. |
Comment author: @gasche Your bug report is hard to understand for someone that does not have the details of the -map mechanism in mind anymore. Let me know if I summarize it correctly. With the file structure you describe, you run $ ocamldep -modules -map top.ml -map foo_map.ml -open Foo -open Top lulz.ml and the output lulz.ml: Bar Foo_map Top is surprising as, from the "-map foo_map", you would expect Bar_mapped instead of Bar. You also note that, as a workaround, reversing the order of the (-map ...) arguments produces the desired output. In the previous case the description was simple and the fix trivial. Here it's more complex and I see no trivial fix, so I'll leave it to someone that wants to look more closely at the code. |
Comment author: antron Yes, sorry. Basically, when one map contains an alias for another map, I would have expected the "top-level" map to have to be provided to ocamldep before the "nested" map, the same order as for "-open". I'm actually not quite sure why the order should matter at all. Leaving this to be looked at seems reasonable to me. |
Comment author: @garrigue The idea of the -map mechanism is to build a map bottom up. I admit that this is not so intuitive, as aliases allow some kind of dependency loops, so it is no longer so clear which one should come first. But the idea is still the same, it is just that some information is not needed early on. |
Comment author: antron Fair enough. Leaving it as is seems reasonable, so I suppose this can be closed. It seems to me that different maps can only "interact" with each other in ocamldep through the aliases they introduce. If that's so, is it possible to relax the need for ordering -map options? This is a hypothetical question. I don't actually have a use for such a relaxation in mind. |
Original bug ID: 7249
Reporter: antron
Assigned to: @garrigue
Status: closed (set by @mshinwell on 2016-09-07T15:07:02Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 4.03.0
Category: tools (ocaml{lex,yacc,dep,debug,...})
Bug description
This seems analogous to #7248
Steps to reproduce
This sets up a module structure "Foo.Bar.a", with two levels of mapping to get from the top level to the implementation of Bar.
The top level map:
top.ml:
module Foo = Foo_map
The map for "namespace" Foo:
foo_map.ml:
module Bar = Bar_mapped
"Lulz" is supposed to be some sibling module of Bar, so we would want to compile it with -open Foo, and be able to reference Bar directly:
lulz.ml:
let a = Bar.a
The correct invocation in 4.03.0 to do this is (correct output immediately below):
$ ocamldep -modules -map foo_map.ml -map top.ml -open Foo -open Top lulz.ml
lulz.ml: Bar_mapped Foo_map Top
However, I would have expected (the output is incorrect):
$ ocamldep -modules -map top.ml -map foo_map.ml -open Foo -open Top lulz.ml
lulz.ml: Bar Foo_map Top
The -open options are also backwards above – these steps are without the fix in trunk.
The text was updated successfully, but these errors were encountered: