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
Make -open support module paths #7137
Comments
Comment author: @gasche That seems like a reasonable request. Would you provide a patch implementing this feature? Besides, the failure mode when passing a non-atomic path today is not very good usability-wise: $ ocamlc -open Scanf.Scanning -i test.ml $ ocaml -open Scanf.Scanning Fatal error: exception Typetexp.Error(_, _, _) |
Comment author: aalekseyev I don't have a patch right now, but I may provide one eventually. |
Comment author: aalekseyev This is my patch. It seems to work on simple examples and the tests in testsuite/tests/tool-ocamldep-modalias pass, but I'm not sure if this is the only place in the code this command line flag is parsed. diff --git a/driver/compmisc.ml b/driver/compmisc.ml
let initial_env () = |
Comment author: @gasche The patch goes in the right direction, but it needs a bit more work:
|
Comment author: aalekseyev Thanks, I'll do this. |
Comment author: aalekseyev I did most of these things, except for error handling. For better or worse, Longident.parse can not fail so it doesn't seem necessary. I tried to change the type of open_modules command like flag to Longident.t to make parsing closer to where it should be, but that introduces a dependency cycle util -> parsing -> util that needs Makefile changes so I reverted that change. From 0ccbff9992c907f3296f187806dc1cb04eabc3ab Mon Sep 17 00:00:00 2001 Changes | 7 +++++++ diff --git a/Changes b/Changes
OCaml 4.03.0:diff --git a/driver/compmisc.ml b/driver/compmisc.ml
let initial_env () =
+byte: b.cmo
+a.cmo: A.ml
+b.cmo: B.ml
+BASEDIR=../..
-- |
Comment author: @mshinwell @aalekseyev Please open a Github pull request with your patch so we can close this issue. |
Comment author: aalekseyev This is now PR#960 |
Original bug ID: 7137
Reporter: aalekseyev
Status: closed (set by @mshinwell on 2016-12-09T11:39:19Z)
Resolution: duplicate
Priority: normal
Severity: minor
Target version: 4.03.1+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @lpw25 @hcarty
Bug description
Currently -open expects a module name, not a module path. This seems overly restrictive. Can we start supporting module paths?
Steps to reproduce
echo 'module B = struct let x = 8 end' > a.ml
echo 'let y = x' > c.ml
ocamlopt.opt -c a.ml
ocamlopt.opt -open A.B -c c.ml
Additional information
One might want to use a workaround [-open A -open B], but that additionally brings in scope other definitions from [A], which is not desirable.
The text was updated successfully, but these errors were encountered: