-
Notifications
You must be signed in to change notification settings - Fork 230
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
module with type constraint crashes merlin #1322
module with type constraint crashes merlin #1322
Comments
I copy-pasted your example on my editor using OCaml-LSP, tried to hover on a few parts of it, but could not produce a crash. Can you give more precise instructions on how you trigger the crash ? |
You need to build first, if it doesn't have a config it works. Build it using dune, then hover it. Repro repo below Editor: VSCode |
Thank you I was able to reproduce the crash.
This comes from I guess it is bad that Merlin reports this failure instead of the expected error which is:
@trefis do you have an idea of what is happening here ? |
Surprisingly it only happens after building: $ dune clean
$ ocamlmerlin single errors -filename hover_this.ml < hover_this.ml| jq
{
"class": "return",
"value": [
{
"type": "config",
"sub": [],
"valid": true,
"message": "No config found for file \"hover_this.ml\" in \".\". Try calling `dune build`."
},
{
"start": {
"line": 5,
"col": 2
},
"end": {
"line": 7,
"col": 23
},
"type": "typer",
"sub": [],
"valid": true,
"message": "In this `with' constraint, the new definition of t\ndoes not match its original definition in the constrained signature:\nType declarations do not match:\n type 'a t = 'a option constraint 'a = int\nis not included in\n type 'a t\nTheir constraints differ.\nFile \"hover_this.ml\", line 2, characters 2-11: Expected declaration\nFile \"hover_this.ml\", line 6, characters 9-54: Actual declaration"
}
],
"notifications": [],
"timing": {
"clock": 19,
"cpu": 4,
"query": 1,
"pp": 0,
"reader": 1,
"ppx": 0,
"typer": 2,
"error": 0
}
}
$ dune build
File "hover_this.ml", lines 5-7, characters 2-23:
5 | ..Monad
6 | with type 'a t = 'a option
7 | constraint 'a = int
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match:
type 'a t = 'a option constraint 'a = int
is not included in
type 'a t
Their constraints differ.
File "hover_this.ml", line 2, characters 2-11: Expected declaration
File "hover_this.ml", lines 6-7, characters 9-23: Actual declaration
$ ocamlmerlin single errors -filename hover_this.ml < hover_this.ml| jq
{
"class": "failure",
"value": "Graph.add: type already defined",
"notifications": [],
"timing": {
"clock": 25,
"cpu": 7,
"query": 3,
"pp": 0,
"reader": 1,
"ppx": 0,
"typer": 2,
"error": 0
}
} |
|
Probably because short paths is only turned on after dune prints the merlin config that enables short-paths. I fixed a similar issue recently: ocaml/ocaml-lsp#429 the pretty printing code was causing a similar exceptions. |
Cherry-picking the change in ocaml/ocaml#10382 fixes this issue. |
CHANGES: Mon Jul 26 11:12:21 PM CET 2021 + merlin binary - Mbrowse.select_leaf: correctly ignore merlin.hide (ocaml/merlin#1376) - enable `occurences` to work when looking for locally abstract types (ocaml/merlin#1382) - handle `-alert` compiler flag (ocaml/merlin#1401) - avoid a race condition when the process started to read a configuration file crashes/is not found (ocaml/merlin#1378, @antalsz) - log the backtrace even when the exception is a Failure (ocaml/merlin#1377, @antalsz) - ignore `-error-style` compiler flag (ocaml/merlin#1402, @nojb) - fix handling of record field expressions (ocaml/merlin#1375) - allow -pp to return an AST (ocaml/merlin#1394) - fix merlin crashing due to short-paths (ocaml/merlin#1334, fixes ocaml/merlin#1322) + editor modes - update quick setup instructions for emacs (ocaml/merlin#1380, @ScriptDevil) + test suite - improve record field destruction testing (ocaml/merlin#1375)
CHANGES: Mon Jul 26 11:12:21 PM CET 2021 + ocaml support - add support for 4.13 - stopped actively supporting version older than 4.12 + merlin binary - Mbrowse.select_leaf: correctly ignore merlin.hide (ocaml/merlin#1376) - enable `occurences` to work when looking for locally abstract types (ocaml/merlin#1382) - handle `-alert` compiler flag (ocaml/merlin#1401) - avoid a race condition when the process started to read a configuration file crashes/is not found (ocaml/merlin#1378, @antalsz) - log the backtrace even when the exception is a Failure (ocaml/merlin#1377, @antalsz) - ignore `-error-style` compiler flag (ocaml/merlin#1402, @nojb) - fix handling of record field expressions (ocaml/merlin#1375) - allow -pp to return an AST (ocaml/merlin#1394) - fix merlin crashing due to short-paths (ocaml/merlin#1334, fixes ocaml/merlin#1322) + editor modes - update quick setup instructions for emacs (ocaml/merlin#1380, @ScriptDevil) + test suite - improve record field destruction testing (ocaml/merlin#1375)
CHANGES: Mon Jul 26 11:12:21 PM CET 2021 + merlin binary - Mbrowse.select_leaf: correctly ignore merlin.hide (ocaml/merlin#1376) - enable `occurences` to work when looking for locally abstract types (ocaml/merlin#1382) - handle `-alert` compiler flag (ocaml/merlin#1401) - avoid a race condition when the process started to read a configuration file crashes/is not found (ocaml/merlin#1378, @antalsz) - log the backtrace even when the exception is a Failure (ocaml/merlin#1377, @antalsz) - ignore `-error-style` compiler flag (ocaml/merlin#1402, @nojb) - fix handling of record field expressions (ocaml/merlin#1375) - allow -pp to return an AST (ocaml/merlin#1394) - fix merlin crashing due to short-paths (ocaml/merlin#1334, fixes ocaml/merlin#1322) + editor modes - update quick setup instructions for emacs (ocaml/merlin#1380, @ScriptDevil) + test suite - improve record field destruction testing (ocaml/merlin#1375)
I'm actually using
ocaml-lsp
but this seems to be caused by the code on the editor, so probably it's merlin fault. The following code crashes theocaml-lsp
, by removing theconstraint
part it stops crashing, but of course it doesn't do the same thing.The text was updated successfully, but these errors were encountered: