fortran-lang / fortls

fortls - Fortran Language Server
https://fortls.fortran-lang.org/
MIT License
258 stars 41 forks source link

External function incorrectly detected as duplicate declaration #406

Open albertziegenhagel opened 5 months ago

albertziegenhagel commented 5 months ago

Describe the bug When the same external function is declared in two separate subroutines, fortls might report the second one as a duplicate declaration.

In the following code

subroutine foo
  integer bar
  external bar

end subroutine foo

subroutine foo2
  integer bar
  external bar

end subroutine foo2

fortls reports an error (Variable "bar" declared twice in scope) in the line external bar in the foo2 subroutine (see the screenshot below).

To Reproduce Given the code above in a file test_external_duplicates.f90, executing

python -m fortls --debug_diagnostics --debug_filepath=test_external_duplicates.f90

gives

Testing "textDocument/publishDiagnostics" request:
  File = "C:\source\fortls\test\test_source\diag\test_external_duplicates.f90"
================================================================================
Reported Diagnostics:
      8:ERROR  "Variable "bar" declared twice in scope"
================================================================================

Expected behavior I would expect that no error is being reported.

Screenshots & Animations image

Setup information (please complete the following information):