Skip to content
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

Hover of a mutually recursive type can cause a stack overflow #1755

Open
Chaarlesss opened this issue Apr 30, 2024 · 4 comments
Open

Hover of a mutually recursive type can cause a stack overflow #1755

Chaarlesss opened this issue Apr 30, 2024 · 4 comments
Labels

Comments

@Chaarlesss
Copy link

Chaarlesss commented Apr 30, 2024

Hi,

Merlin produces a stack overflow which causes Emacs to freeze when hovering the type b on line 1 of the following code:

type a = A | B of int * b
and b = a list

Strangely, the problem does not occur when hovering the type a on line 2.

I am using Merlin 4.14-501 with OCaml 5.1.1.

The end of the stack trace is:
stack trace

@voodoos
Copy link
Collaborator

voodoos commented Apr 30, 2024

Thank for your report @Chaarlesss.

Are you using merlin mode or an lsp mode ?

Could it be that your "hover" query has a high verbosity by default ?

@Chaarlesss
Copy link
Author

I am using merlin mode (with merlin-eldoc).

To clarify, I found this error in the log's buffer and does not appear when the problem occurs.

I guess the freeze may come from my own configuration of Emacs (which is roughly Doom Emacs with the OCaml module), but I think that the underlying problem may come from Merlin.

I also tried to reproduce this in VSCode (standard setup with OCamlPlatform), and I also get a strange result (but I am not sure Merlin the one in cause here):
image

@voodoos
Copy link
Collaborator

voodoos commented Apr 30, 2024

Looking into eglot, it does seems that there is a verbosity setting that can be min or max. You might want to set that on min.

Verbosity was not meant to be always set on max and it can lead to strange issues with recursive types.

While setting verbosity to min might be a workaround I agree that the behavior of Merlin is not satisfying here, it would be worth to have a look.

@Chaarlesss
Copy link
Author

Changing the verbosity fixed indeed the freezing. Thanks for pointing me to this solution !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants