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

Cannot disable short-paths #1395

Open
Sakarah opened this issue Nov 15, 2024 · 3 comments
Open

Cannot disable short-paths #1395

Sakarah opened this issue Nov 15, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@Sakarah
Copy link

Sakarah commented Nov 15, 2024

As stated in issue #1227, short-paths usually gives weird behaviors for code using type aliases.

In the OCaml compiler, this issue can sometimes be mitigated by not using the -short-paths option to force displaying full paths in error messages. Such types are usually longer but at least they are similar to the declared function signature.

With OCaml LSP, such a mitigation seems inaccessible with the current implementation. The -short-path option is always enabled by default. If I understand correctly, passing the real_path option to the underlying Merlin should disable this path shortening and give a behavior that is similar to the compiler without the -short-paths option.

Ideally, I would like to be able to use OCaml LSP with Merlin in real_paths mode for some projects, and in the current short_paths mode for others.

@voodoos
Copy link
Collaborator

voodoos commented Nov 18, 2024

If you use Dune then it passes the build flags to Merlin / LSP. This means that removing short paths from the standard ocaml flags set might allow you to disable the feature. It can be done in dune and dune-workspace files:

(env
 (_
  (flags ((:standard \ -short-paths)))))

It remains to be checked that short-paths is the issue here.

@Sakarah
Copy link
Author

Sakarah commented Nov 18, 2024

For the specific flag -short-paths it seems that its absence is completely ignored by OCaml LSP.

With the dune file:

(library
  (name test)
  (modes byte native))

(env
 (_
  (flags ((:standard \ -short-paths)))))

and ML file:

type nat = int

let incr : int -> int = (+) 1

let () =
  ignore (incr true)

dune build gives the intended Error: This expression has type bool but an expression was expected of type int.
However, OCaml LSP writes This expression has type bool but an expression was expected of type nat in the error list.

@voodoos
Copy link
Collaborator

voodoos commented Nov 18, 2024

Right, it looks like short-path is forced to be true in a few places indeed.

@voodoos voodoos added the enhancement New feature or request label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants