hansec / fortran-language-server

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

Use-directive ordering issue #184

Open mystery-e204 opened 3 years ago

mystery-e204 commented 3 years ago

I have a situation like this:

module mod_a
   integer, parameter   :: q_a = 4
end module

module mod_b
   use mod_a
   integer, parameter   :: q_b = 8
end module

program test
   use mod_b,  only: q_b
   use mod_a

   real(q_a) :: r_a
   real(q_b) :: r_b
end program test

It compiles and runs fine but fortls states that q_a on line 14 cannot be found in the scope. The problem disappears if you swap the order of the use directives in the main program.

My guess is that because of the use mod_a on line 6, fortls does not parse mod_a a second time in the main program. However, since only q_b was included from mod_b, q_a never gets properly included.

gnikit commented 2 years ago

@manie204 BTW This has now been fixed at fortls. I just forgot to update the issue on github.

mystery-e204 commented 2 years ago

@gnikit Thanks for bringing this to my attention. I was unaware of your fork since I haven't been coding in Fortran for a while. I will check it out and also thanks for the fix.