Confusing scoping of variable #156
-
Let's check this simple code module mod1
implicit none
private
integer :: x = 10
end module mod1
program name
use mod1
implicit none
call test()
contains
subroutine test()
integer :: x
print *, x
end
end program name Now for this code, the linter shows warning (for the declaration statement inside that subroutine)
But the |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
That is strange. It does not seem to be a bug on the server side but it could be an issue with your configuration ( fortls --debug_filepath tmp.f90 --debug_rootpath . --debug_diagnostics and fortls --debug_filepath tmp.f90 --debug_rootpath . --debug_parser and reply with the outputs. What you should be seeing is something along these lines
|
Beta Was this translation helpful? Give feedback.
-
These are the output Testing "initialize" request:
Root = "."
Succesful!
Source directories:
.
Testing "textDocument/publishDiagnostics" notification:
File = "test.f90"
Reported errors or warnings:
13:WARNING "Variable "x" masks variable in parent scope" and Testing parser
File = "test.f90"
Detected format: free
=========
Parser Output
=========
=== No PreProc ===
module mod1 !!! MODULE statement(1)
implicit none !!! IMPLICIT statement(2)
integer :: x = 10 !!! VARIABLE statement(4)
end module mod1 !!! END "MODULE" scope(5)
program name !!! PROGRAM statement(8)
use mod1 !!! USE statement(9)
implicit none !!! IMPLICIT statement(10)
contains !!! CONTAINS statement(12)
subroutine test() !!! SUBROUTINE statement(13)
integer :: x !!! VARIABLE statement(14)
end !!! END "None" scope(16)
end program name !!! END "PROGRAM" scope(17)
=========
Object Tree
=========
1: mod1
6: mod1::x
1: name
2: name::test
6: name::test::x
2: name::test
6: name::test::x
=========
Exportable Objects
=========
1: mod1
1: name |
Beta Was this translation helpful? Give feedback.
-
What version of |
Beta Was this translation helpful? Give feedback.
-
You were right. I was using an old version of |
Beta Was this translation helpful? Give feedback.
What version of
fortls
are you using? These outputs do not match the output format of the latestfortls
version. See the difference on how line numbers are reported and how your version number is missing.Install instructions