From fce235d1b013f347709033f2a470e0fcb7b5431e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulysse=20G=C3=A9rard?= Date: Tue, 15 Oct 2024 14:59:43 +0200 Subject: [PATCH] Add reproduction from issue #1848 --- tests/test-dirs/locate/issue1848.t | 71 ++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/test-dirs/locate/issue1848.t diff --git a/tests/test-dirs/locate/issue1848.t b/tests/test-dirs/locate/issue1848.t new file mode 100644 index 000000000..da2d95fe9 --- /dev/null +++ b/tests/test-dirs/locate/issue1848.t @@ -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 + } + }