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

bug: Error hovering an associated function #269

Closed
minhqdao opened this issue Mar 19, 2023 · 10 comments · Fixed by #280
Closed

bug: Error hovering an associated function #269

minhqdao opened this issue Mar 19, 2023 · 10 comments · Fixed by #280
Assignees
Labels
bug Something isn't working lsp/hover Issues related with hovering requests

Comments

@minhqdao
Copy link

minhqdao commented Mar 19, 2023

When I use the Modern Fortran plugin in VSCode and hover hi in this little piece of code:

program main
  implicit none

  associate (hi => say_hi())
    if (hi) print *, 'Bye'
  end associate

contains

  logical function say_hi()
    print *, 'Hi'
    say_hi = .true.
  end

end program

I get this error message:

Screenshot 2023-03-19 at 22 51 04

The program, however, runs normally and prints:

Hi
Bye

Specs

  • macOS Ventura 13.2.1, M1
  • Visual Studio Code 1.76.2
  • Modern Fortran v3.2.0, but the same is observed on the pre-release version v3.4.2023030801
  • fortls 2.13.0, installed via Homebrew
  • Python 3.11.2

Related Issues: #214, #108

@minhqdao minhqdao added the bug Something isn't working label Mar 19, 2023
@Carltoffel
Copy link
Member

Carltoffel commented May 12, 2023

I have a possibly related bug: A function can be elemental (or not) but as soon as it is also logical or any other type, I will no longer get the docstring in the tooltip.

Minimal example:

program main
    ! type a or be here:

contains

function a()
    !! this shoes up
    logical a
    a = .true.
end function

logical function b()
    !! this doesn't
    b = .false.
end function

end program main

image
image

v2.13.0 in neovim v0.9.0

@gnikit
Copy link
Member

gnikit commented May 15, 2023

I completely missed this @minhqdao, will have a look

@gnikit gnikit self-assigned this May 16, 2023
@gnikit
Copy link
Member

gnikit commented May 16, 2023

Traceback:

Traceback (most recent call last):
  File "/home/gn/Code/Python/fortls/venv/bin/fortls", line 8, in <module>
    sys.exit(main())
  File "/home/gn/Code/Python/fortls/fortls/__init__.py", line 45, in main
    debug_server_general(args, vars(args))
  File "/home/gn/Code/Python/fortls/fortls/__init__.py", line 290, in debug_server_general
    hover_results = s.serve_hover(
  File "/home/gn/Code/Python/fortls/fortls/langserver.py", line 1111, in serve_hover
    var_obj.get_hover_md(long=True).replace(
  File "/home/gn/Code/Python/fortls/fortls/objects.py", line 1810, in get_hover_md
    return fortran_md(*self.get_hover(long, drop_arg))
  File "/home/gn/Code/Python/fortls/fortls/objects.py", line 1801, in get_hover
    hover_str = ", ".join([self.get_desc()] + self.get_keywords())
  File "/home/gn/Code/Python/fortls/fortls/objects.py", line 1817, in get_keywords
    return get_keywords(self.link_obj.keywords, self.link_obj.keyword_info)
AttributeError: 'Function' object has no attribute 'keyword_info'

gnikit added a commit that referenced this issue May 16, 2023
I think the signature is still not ideal
i.e. `LOGICAL FUNCTION` but I chose it
since it indicates that the associate block
variable is the result of a function.

Fixes #269
@gnikit gnikit added the lsp/hover Issues related with hovering requests label May 16, 2023
@github-project-automation github-project-automation bot moved this from To do to Done in fortls v3.0.0 May 16, 2023
@Carltoffel
Copy link
Member

I completely missed this @minhqdao, will have a look

Was the bug I mentioned related, or should I open a new bug report? :)

@gnikit
Copy link
Member

gnikit commented May 17, 2023

Hey @Carltoffel so there is a difference in the hover signatures, but you can always see the documentation.
Screenshot from 2023-05-17 10-37-25
Screenshot from 2023-05-17 10-39-25

@Carltoffel
Copy link
Member

Ah, thanks. Then it probably is a problem with the LSP implementation in neovim.

@gnikit
Copy link
Member

gnikit commented May 17, 2023

The inconsistency between the 2 docstrings is tracked in #281.

@gnikit
Copy link
Member

gnikit commented May 17, 2023

I will try and issue a pre-release for v3.0.0 for people to be able to download from PyPi (although the pre-release version will still have a lower precedence over the stable releases, so it won't be installed automatically).

In the meantime you can try the latest fortls version which includes a bunch of bug fixes, performance improvements and a new Markdown docstring parser via:

pip install git+https://github.com/fortran-lang/fortls.git

@Carltoffel
Copy link
Member

Thank you!
I'm not sure if I installed the correct version (2.13.1.dev156+g6a82432) but it looks better now:

image

However, the format is still messed up.

@gnikit
Copy link
Member

gnikit commented May 18, 2023

So the new hover results, take the docstrings and assemble them in markdown. Then the client (VSCode, neovim, Emacs, etc. ) Is meant to render that markdown. Not sure why neovim is lagging behind on that https://www.reddit.com/r/neovim/comments/tx40m2/is_it_possible_to_improve_lsp_hover_look/

Currently there is no way to use the old style docs (it was to expensive to maintain both types of docs assembly processes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lsp/hover Issues related with hovering requests
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants