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

Failure to report short paths with intervening packages #1643

Open
goldfirere opened this issue Jun 28, 2023 · 7 comments
Open

Failure to report short paths with intervening packages #1643

goldfirere opened this issue Jun 28, 2023 · 7 comments

Comments

@goldfirere
Copy link
Contributor

Suppose I have

open Core

let _ = Filename.dirname

and ask for the type of the _ (with -short-paths). I get Base.string -> Base.string, instead of the desired string -> string. This seems like a bug.

My testing setup: a dune project, with this dune file:

(library
 (public_name merlin_bug)
 (name merlin_bug)
 (libraries core))

After building, this invocation shows the Base.string -> Base.string type:

ocamlmerlin single type-enclosing -position 3:4 -index 0 -filename merlin_bug.ml -verbosity 0 -short-paths < merlin_bug.ml
@voodoos
Copy link
Collaborator

voodoos commented Jun 28, 2023

I don't think this is an issue with -short-paths. The type of Core.Filename.dirname really is Base.string -> Base.string: https://ocaml.org/p/core/v0.16.0/doc/Core/Filename/index.html#val-dirname

Since Base is not opened there is no reason for short path to remove these prefixes.

@goldfirere
Copy link
Contributor Author

But Base.string is an abbreviation for string. Is that not what -short-paths is trying to address?

@trefis
Copy link
Contributor

trefis commented Jun 29, 2023

But has base actually been loaded?
The aim of -short-paths is to use the information it already has in the typing environment but to avoid loading any more cmi files.

@goldfirere
Copy link
Contributor Author

Ah -- I didn't realize that.

I edited the file to be

open Core

module Foo = Base.Int

let _ = Filename.dirname

which would seem to force loading of Base. But I still see Base.string -> Base.string in the output (after adjusting the line number).

@voodoos
Copy link
Collaborator

voodoos commented Jul 5, 2023

In my attempt I was able to get the short paths by doing:

open Base
open Core

let _ = Filename.dirname

@goldfirere
Copy link
Contributor Author

That doesn't surprise me. But I would expect not to need to open Base to get the short paths -- that is, unless I'm misunderstanding the goal of -short-paths.

@goldfirere
Copy link
Contributor Author

To expand a bit: My understanding of -short-paths is that it instructs OCaml / merlin to produce the shortest path it knows that is equal to a given path. string is definitely shorter than Base.string. And, regardless of what is opened, the compiler has access to the knowledge that Base.string = string. So, perhaps I have my picture of -short-paths wrong, or maybe my picture of what the compiler knows is wrong. But my last example above, which uses Base directly, seems to suggest that even if Base is all loaded (and thus that the compiler really does know that Base.string = string), it still doesn't produce the shortest path.

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

No branches or pull requests

3 participants