Skip to content

Commit

Permalink
Add reproduction from issue ocaml#1848
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Oct 15, 2024
1 parent 02cf198 commit fce235d
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions tests/test-dirs/locate/issue1848.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Create a module with an mli file
$ cat > foo.ml << EOF
> type t = Foo
> module Bar = struct
> type t = Bar
> end
> EOF

$ cat > foo.mli << EOF
> module Bar : sig
> type t
> end
> type t
> EOF

$ $OCAMLC -c -bin-annot foo.mli
$ $OCAMLC -c -bin-annot foo.ml

Locate the Bar on line 4
$ cat > test1.ml << EOF
> module type Foo = sig
> include module type of Foo
> module Bar : sig
> include module type of Bar
> end
> end
> EOF

The expected location is 2:7 of foo.ml, but it instead goes to 1:9, which is the
constructor Foo
$ $MERLIN single locate -position 4:28 -look-for ml \
> -filename test1.ml < test1.ml | jq .value
{
"file": "$TESTCASE_ROOT/foo.ml",
"pos": {
"line": 1,
"col": 9
}
}

Locate the Bar on line 3
$ cat > test2.ml << EOF
> include Foo
> module Bar = struct
> include Bar
> end
> EOF

Correctly returns 2:7
$ $MERLIN single locate -position 3:12 -look-for ml -filename test2.ml < test2.ml | jq .value
{
"file": "$TESTCASE_ROOT/foo.ml",
"pos": {
"line": 2,
"col": 7
}
}

Locate the Foo.Bar on line 1
$ cat > test3.ml << EOF
> include module type of Foo.Bar
> EOF
Correctly returns 2:7
$ $MERLIN single locate -position 1:28 -look-for ml -filename test3.ml < test3.ml | jq .value
{
"file": "$TESTCASE_ROOT/foo.ml",
"pos": {
"line": 2,
"col": 7
}
}

0 comments on commit fce235d

Please sign in to comment.