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

Toplevel #use with relative paths have different behavior between 4.02.3 and 4.03.0 #7347

Closed
vicuna opened this issue Sep 8, 2016 · 4 comments
Labels
Milestone

Comments

@vicuna
Copy link

vicuna commented Sep 8, 2016

Original bug ID: 7347
Reporter: sebmondet
Status: resolved (set by @xavierleroy on 2017-02-18T15:13:18Z)
Resolution: fixed
Priority: normal
Severity: text
Version: 4.03.0
Target version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1
Category: ~DO NOT USE (was: OCaml general)
Child of: #6081

Bug description

Since 4.03.0, the #use directive seems to treat "file.ml" and "./file.ml" differently:

  • the "file.ml" one seems to be relative to the script.
  • the "./file.ml" one seems to be relative to the current-directory of the ocaml process.

(Doesn't seem to be in the changelog:

ocaml/Changes

Line 841 in bf6261c

### Toplevel and debugger:
)

Steps to reproduce

example/ex.ml:

#use "same_dir.ml"

#use "./dot_slash.ml"


let () = Printf.printf "%s, %s\n%!" Same_dir.(hello ()) Dot_slash.(hello ())

example/same_dir.ml

module Same_dir = struct let hello () = "same-dir" end

example/dot_slash.ml:

module Dot_slash = struct let hello () = "dot-slash" end

With 4.02.0

$ ocaml -version
The OCaml toplevel, version 4.02.3
$ ocaml example/ex.ml
Cannot find file same_dir.ml.
Cannot find file ./dot_slash.ml.
File "example/ex.ml", line 7, characters 36-44:
Error: Unbound module Same_dir
$ cd example/ ; ocaml ex.ml
same-dir, dot-slash

With 4.03.0

It finds same_dir.ml.

$ ocaml -version
The OCaml toplevel, version 4.03.0
$ ocaml example/ex.ml
Cannot find file ./dot_slash.ml.
File "./example/ex.ml", line 7, characters 56-65:
Error: Unbound module Dot_slash
$ cd example/ ; ocaml ex.ml
same-dir, dot-slash

@vicuna
Copy link
Author

vicuna commented Sep 27, 2016

Comment author: @damiendoligez

That's #6081 and it is in the change log for 4.03.0.

Do you want to argue that we should revert it? I think the new behaviour is much better for scripts.

@vicuna
Copy link
Author

vicuna commented Sep 27, 2016

Comment author: sebmondet

I don't know :)
It was just a surprising way of breaking a script I had running on TravisCI.

At least, having "file.ml" and "./file.ml" have the same behavior and/or documenting it would be nice?

@vicuna
Copy link
Author

vicuna commented Sep 27, 2016

Comment author: @damiendoligez

We'll document it, but really it is the standard behaviour for the compilers: if you say "file.cma" it looks in the library path, and if you say "./file.cma" it looks in the current directory. In fact, the shell does the same for commands.

@vicuna
Copy link
Author

vicuna commented Feb 18, 2017

Comment author: @xavierleroy

Documentation added in manual, chapter "Toplevel", version 4.05 and up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant