hansec / fortran-language-server

Fortran Language Server for the Language Server Protocol
MIT License
295 stars 57 forks source link

Renamed procedure in use statment not recognized #137

Open mystery-e204 opened 5 years ago

mystery-e204 commented 5 years ago

When renaming an external/module procedure name in the local namespace via "use", it is not recognized by Intellisense. In issue #109, this problem was already addressed for the case of variable names.

Here is a MWE of a potentially tricky case:

module test_module
   implicit none

   contains

   function func_1(x) result(out)
      integer              :: out
      integer, intent(in)  :: x
      out = x + 1
   end function
end module test_module

program test
   use test_module, func_1_ref => func_1
   implicit none

   logical  :: func_1
   func_1 = .true.

   write(*, *) func_1
   write(*, *) func_1_ref(3)
end program test

In the main program's scope, func_1 is a valid variable name that is correctly recognized as logical by Intellisense. However, in the line containing the use statement, func_1 is incorrectly identified as a logical variable as well. As stated above, func_1_ref is not recognized.

hansec commented 4 years ago

Sorry about the delay and thanks for the report. In the current version 1.10.3 I am not able to fully reproduce your bug. In particular, func_1_ref seems to be recognized as expected. I do see the issue with func_1 on the USE line. Can you verify you still see the buggy behavior?

mystery-e204 commented 4 years ago

Sorry, I was absent for a few days myself. That is odd. I copied the MWE I posted above into a fresh editor window and still see the same behavior. All extension are up-to-date and fortls shows version 1.10.3 on python3.7.3. The only non-default option I have set is variableHover but that doesn't change the outcome.

My VSCode version info: Version: 1.41.1 Commit: 26076a4de974ead31f97692a0d32f90d735645c0 Date: 2019-12-18T15:04:31.999Z Electron: 6.1.5 Chrome: 76.0.3809.146 Node.js: 12.4.0 V8: 7.6.303.31-electron.0 OS: Linux x64 4.15.0-65-generic