You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dune RPC should return the same diagnostic as the OCaml compiler
Actual Behavior
Some lines are off by one but it doesn't look like it's consistent
Reproduction
I have this simple file:
module type A=sigvala : intvalb : floatendmoduleM (A : A) =structlet a =A.a +A.a
endmoduleAI=structlet a =3let b =4endmoduleMI=M (AI)
When compiling I have the following error:
File "bin/main.ml", line 15, characters 12-18:
15 | module MI = M (AI)
^^^^^^
Error: Modules do not match: sig val a : int val b : int end
is not included in A
Values do not match: val b : int is not included in val b : float
The type int is not compatible with the type float
File "bin/main.ml", line 3, characters 2-15: Expected declaration
File "bin/main.ml", line 12, characters 6-7: Actual declaration
If I replace A.a + A.a with A.a + A.b I have the following compilation error:
File "bin/main.ml", line 7, characters 16-19:
7 | let a = A.a + A.b
^^^
Error: The value A.b has type float but an expression was expected of type
int
But if I start an LSP server with a dune watch process I receive the following diagnostic:
("/home/mattias/test_ocaml/bin/main.ml"
((:message"The value \"A.b\" has type \"float\" but an expression was expected of type\n\"int\"":range (:end (:character19:line6) :start (:character16:line6))
:severity1:source"dune")
(:message"Modules do not match: sig val a : int val b : int end is not included in \nA\nValues do not match: val b : int is not included in val b : float\nThe type int is not compatible with the type float":range (:end (:character18:line14) :start (:character12:line14))
:relatedInformation
[(:location
(:range (:end (:character15:line3) :start (:character2:line3)) :uri"file:///home/mattias/test_ocaml/bin/main.ml")
:message"Expected declaration")
(:location
(:range (:end (:character7:line12) :start (:character6:line12)) :uri"file:///home/mattias/test_ocaml/bin/main.ml")
:message"Actual declaration")]
:severity1:source"ocamllsp")))
As you can see
the first error is located at line 6, off by -1
the second error is located at line 14, off by -1
the related information are located at line 3 and 12
Now if I fix this file and create its corresponding mli file with the following content
module type A=sigvala : intvalb : intend
I receive the following diagnostic:
("/home/mattias/test_ocaml/bin/main.ml"
((:message"The implementation \"bin/main.ml\"\ndoes not match the interface \"bin/main.ml\": \nModule type declarations do not match:\n module type A = sig val a : int val b : float end\ndoes not match\n module type A = sig val a : int val b : int end\nAt position \"module type A = <here>\"\nModule types do not match:\n sig val a : int val b : float end\nis not equal to\n sig val a : int val b : int end\nAt position \"module type A = <here>\"\nValues do not match: val b : float is not included in val b : int\nThe type \"float\" is not compatible with the type \"int\"":range (:end (:character0:line0) :start (:character0:line0))
:relatedInformation
[(:location
(:range (:end (:character13:line2) :start (:character2:line2)) :uri"file:///home/mattias/test_ocaml/bin/main.mli")
:message"Expected declaration")
(:location
(:range (:end (:character15:line2) :start (:character2:line2)) :uri"file:///home/mattias/test_ocaml/bin/main.ml")
:message"Actual declaration")]
:severity1:source"dune")))
This time, the related information are located at line 2, off by -1.
This inconsistent behaviour prevents me from saying "increment line by one unless you're formatting a related information part".
Specifications
Version of dune (output of dune --version): 3.17.2
Version of ocaml (output of ocamlc --version): 5.3.0
Operating system (distribution and version):
OS: cachyos rolling
Kernel: x86_64 Linux 6.14.2-2-cachyos
The text was updated successfully, but these errors were encountered:
No, if I just compile with dune build I have the proper error reporting because they're reported by the ocaml-lsp and not by the dune watch rpc. Here is the same error reported by dune and ocamllsp:
dune (notice line 4 and 13)
(:message"Signature mismatch:Modules do not match: sig val a : int val b : float endis not included in AValues do not match: val b : floatis not included in val b : int -> string -> string -> string -> string -> string -> string -> stringThe type \"float\" is not compatible with the type\"int -> string -> string -> string -> string -> string -> string -> string\"":range (:end (:character3:line14) :start (:character16:line11))
:relatedInformation
[(:location
(:range
(:end (:character77:line4) :start (:character2:line3)) :uri"file:///home/mattias/test_ocaml/bin/main.ml")
:message"Expected declaration")
(:location
(:range
(:end (:character7:line13) :start (:character6:line13)) :uri"file:///home/mattias/test_ocaml/bin/main.ml")
:message"Actual declaration")]
:severity1:source"dune")
ocamllsp (notice line 5 and 14)
(:message"Signature mismatch:Modules do not match: sig val a : int val b : float end is not included in AValues do not match: val b : floatis not included in val b : int -> string -> string -> string -> string -> string -> string -> stringThe type float is not compatible with the type int -> string -> string -> string -> string -> string -> string -> string":range (:end (:character3:line14) :start (:character16:line11))
:relatedInformation
[(:location
(:range
(:end (:character77:line5) :start (:character2:line4)) :uri"file:///home/mattias/test_ocaml/bin/main.ml")
:message"Expected declaration")
(:location
(:range
(:end (:character7:line14) :start (:character6:line14)) :uri"file:///home/mattias/test_ocaml/bin/main.ml")
:message"Actual declaration")]
:severity1:source"ocamllsp")
Uh oh!
There was an error while loading. Please reload this page.
Expected Behavior
Dune RPC should return the same diagnostic as the OCaml compiler
Actual Behavior
Some lines are off by one but it doesn't look like it's consistent
Reproduction
I have this simple file:
When compiling I have the following error:
If I replace A.a + A.a with A.a + A.b I have the following compilation error:
But if I start an LSP server with a dune watch process I receive the following diagnostic:
As you can see
Now if I fix this file and create its corresponding mli file with the following content
I receive the following diagnostic:
This time, the related information are located at line 2, off by -1.
This inconsistent behaviour prevents me from saying "increment line by one unless you're formatting a related information part".
Specifications
dune
(output ofdune --version
): 3.17.2ocaml
(output ofocamlc --version
): 5.3.0The text was updated successfully, but these errors were encountered: