-
Notifications
You must be signed in to change notification settings - Fork 246
Add reproduction for some locate issues #1930
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fef5cec
Add a reproduction case for #1580 and #1588
voodoos 9e894cc
Add a test illustrating issue #1610
voodoos 210feda
Add a test illustrating issue ocaml/merlin#1610
voodoos 6dcf5a7
Illustrate issue #1595
voodoos 732bd24
Add a recovery layer around type_argument.
voodoos d27ff72
Add a test illustration issue #1929
voodoos fb1d5ba
Add a test illustrating #1924 and #1821
voodoos 9bfdb69
Disable all locate test on windows since they almost always print paths.
voodoos 43f62f1
Workaround dune usage of BUILD_PREFIX_MAP to rewrite paths in locate …
voodoos d187548
Add a changelog entry for #1930
voodoos abec239
Don't override BUILD_PATH_PREFIX_MAP in the tests
voodoos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| module Foo = struct | ||
| type t = { foo : int; bar : int } | ||
|
|
||
| let foo = "hello" | ||
| end | ||
|
|
||
| let _ = | ||
| let foo = 10 in | ||
| let bar = 10 in | ||
| ({ Foo.foo; bar } : Foo.t) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| $ cat >dune-project <<'EOF' | ||
| > (lang dune 3.0) | ||
| > EOF | ||
|
|
||
| $ mkdir dep | ||
| $ cat >dep/dep.ml <<'EOF' | ||
| > let txt = "Hello!" | ||
| > EOF | ||
|
|
||
| $ mkdir exe | ||
| $ cat >exe/main.ml << 'EOF' | ||
| > print_endline Dep.txt | ||
| > EOF | ||
|
|
||
| $ cat >exe/dune << 'EOF' | ||
| > (executable | ||
| > (name main)) | ||
| > (copy_files# %{project_root}/dep/*.ml) | ||
| > EOF | ||
|
|
||
| $ dune exec ./exe/main.exe | ||
| Hello! | ||
|
|
||
| $ $MERLIN single errors -filename exe/main.ml <exe/main.ml | jq '.value' | ||
| [] | ||
|
|
||
| FIXME: Dune should also provide a configuration for the original sources | ||
| $ $MERLIN single errors -filename dep/dep.ml <dep/dep.ml | jq '.value' | ||
| [ | ||
| { | ||
| "type": "config", | ||
| "sub": [], | ||
| "valid": true, | ||
| "message": "No config found for file dep/dep.ml. Try calling 'dune build'." | ||
| } | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| This test reproduces the issue described in: | ||
| https://github.com/ocaml/merlin/issues/1934 | ||
|
|
||
|
|
||
| $ cat >dune-project <<EOF | ||
| > (lang dune 2.0) | ||
| > EOF | ||
|
|
||
| $ mkdir lib | ||
| $ cat >lib/lib.ml <<EOF | ||
| > let message = "hello" | ||
| > EOF | ||
| $ cat >lib/dune <<EOF | ||
| > (library | ||
| > (name lib) | ||
| > (preprocess (action (run sed "s/hello/world/g" %{input-file})))) | ||
| > EOF | ||
|
|
||
| $ mkdir lib2 | ||
| $ cat >lib2/lib.ml <<EOF | ||
| > let message = "hello" | ||
| > EOF | ||
| $ cat >lib2/dune <<EOF | ||
| > (library | ||
| > (name lib2) | ||
| > (preprocess (action (run sed "s/hello/world/g" %{input-file})))) | ||
| > EOF | ||
|
|
||
|
|
||
| $ cat >main.ml <<EOF | ||
| > module M = Lib | ||
| > let () = print_endline M.message | ||
| > EOF | ||
|
|
||
| $ cat >dune <<EOF | ||
| > (executable | ||
| > (name main) | ||
| > (libraries lib lib2)) | ||
| > EOF | ||
|
|
||
| $ $DUNE exec ./main.exe | ||
| world | ||
|
|
||
| $ ls _build/default/lib/*.ml | ||
| _build/default/lib/lib.ml | ||
| _build/default/lib/lib.pp.ml | ||
|
|
||
| Merlin should treat Dune's .pp. files in a correct, ad-hoc way. Right it | ||
| appears that the digest of the original source file is not generated properly. | ||
| The current workaround should work in most cases but is not a definitive answer. | ||
| See discussion in [#1934](https://github.com/ocaml/merlin/issues/1934) | ||
| $ $MERLIN single locate locate -look-for ml -position 1:12 -filename main.ml <main.ml | ||
| { | ||
| "class": "return", | ||
| "value": { | ||
| "file": "$TESTCASE_ROOT/lib/lib.ml", | ||
| "pos": { | ||
| "line": 1, | ||
| "col": 0 | ||
| } | ||
| }, | ||
| "notifications": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| Issue #1580: | ||
|
|
||
| $ cat >test.ml << 'EOF' | ||
| > module type S = sig | ||
| > val foo : unit -> ('a -> 'a -> bool) -> unit | ||
| > end | ||
| > | ||
| > module F (M : S) = struct | ||
| > let z () = M.foo () compare | ||
| > end | ||
| > EOF | ||
|
|
||
| $ $MERLIN single errors -filename test.ml <test.ml | ||
| { | ||
| "class": "return", | ||
| "value": [ | ||
| { | ||
| "start": { | ||
| "line": 6, | ||
| "col": 22 | ||
| }, | ||
| "end": { | ||
| "line": 6, | ||
| "col": 29 | ||
| }, | ||
| "type": "typer", | ||
| "sub": [], | ||
| "valid": true, | ||
| "message": "The value compare has type 'a -> 'a -> int | ||
| but an expression was expected of type 'a -> 'a -> bool | ||
| Type int is not compatible with type bool" | ||
| } | ||
| ], | ||
| "notifications": [] | ||
| } | ||
|
|
||
| The typing recovery allows Merlin to perform the correct jump here: | ||
|
|
||
| $ $MERLIN single locate -position 6:16 \ | ||
| > -filename test.ml <test.ml | jq '.value' | ||
| { | ||
| "file": "$TESTCASE_ROOT/test.ml", | ||
| "pos": { | ||
| "line": 2, | ||
| "col": 6 | ||
| } | ||
| } | ||
|
|
||
|
|
||
| $ $MERLIN single locate -position 6:25 \ | ||
| > -filename test.ml <test.ml | jq '.value' | ||
| { | ||
| "file": "lib/ocaml/stdlib.mli", | ||
| "pos": { | ||
| "line": 162, | ||
| "col": 9 | ||
| } | ||
| } | ||
|
|
||
| Issue #1588: | ||
|
|
||
| $ cat >test.ml <<'EOF' | ||
| > let test ~f:(_ : unit -> unit) = () | ||
| > type t = F : { f : unit -> 'fn } -> t | ||
| > let call (F { f }) = test ~f | ||
| > EOF | ||
|
|
||
| $ $MERLIN single locate -position 3:23 \ | ||
| > -filename test.ml <test.ml | jq '.value' | ||
| { | ||
| "file": "$TESTCASE_ROOT/test.ml", | ||
| "pos": { | ||
| "line": 1, | ||
| "col": 4 | ||
| } | ||
| } | ||
|
|
||
| $ $MERLIN single errors -filename test.ml <test.ml | ||
| { | ||
| "class": "return", | ||
| "value": [ | ||
| { | ||
| "start": { | ||
| "line": 3, | ||
| "col": 27 | ||
| }, | ||
| "end": { | ||
| "line": 3, | ||
| "col": 28 | ||
| }, | ||
| "type": "typer", | ||
| "sub": [], | ||
| "valid": true, | ||
| "message": "The value f has type unit -> $fn but an expression was expected of type | ||
| unit -> unit | ||
| Type $fn is not compatible with type unit | ||
| Hint: $fn is an existential type bound by the constructor F." | ||
| } | ||
| ], | ||
| "notifications": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.