hansec / fortran-language-server

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

modules names ending with `_mod` are not recognized #174

Closed JHenneberg closed 3 years ago

JHenneberg commented 3 years ago

Hello,

modules names ending with _mod are not recognized. In Addition a file is created named like the module and an extension .mod. In this case mymodule_mod.mod

main.f90:

program fortls_mod_bug
  use myModule_mod
  implicit none

  call mySubroutine()
end program fortls_mod_bug

myModule.f90:

module myModule_mod
  implicit none
  private
  public :: mySubroutine
contains
  subroutine mySubroutine()
    implicit none

  end subroutine mySubroutine
end module myModule_mod

Appearing error message: Can't open module file 'mymodule_mod.mod' for reading at (1): No such file or directory

hansec commented 3 years ago

Thanks for the report. Unfortunately, I am not able to replicate this myself with the example you provided. Can you provide more detail on the steps to reproduce this problem? Do you get the error on a specific type of request (eg. autocomplete)?

I don't think that fortls should be creating or trying to read files with the *.mod suffix unless something else has been changed. Can you double your settings and let me know what you are using for the project in question?

JHenneberg commented 3 years ago

I have in addition a workspace configured: fortls_bug.code-workspace:

{
    "folders": [
        {
            "path": "."
        }
    ]
}

And I am opening the files using this workspace.

image

"fortran-ls.autocompletePrefix": true,
    "fortran-ls.lowercaseIntrinsics": true,
    "fortran-ls.enableCodeActions": true,
    "fortran-ls.hoverSignature": true,
    "fortran-ls.notifyInit": true,
    "fortran-ls.variableHover": true,
    "fortran.provideCompletion": false,
    "fortran.provideSymbols": false,
    "fortran.provideHover": false,
    "fortran.linterExtraArgs": [],
    "fortran.preferredCase": "lowercase",

I realised when the file with the use statment is opened before the one with the module is openend it is only happening. The File is never the less created as soon as I open myModule.f90.

hansec commented 3 years ago

I think this might be coming from a different extension. The fortls warning about missing modules should be an info warning and has different wording (see screenshot below with intentionally misspelled name). If you have another linter enabled that might be producing the error and would also explain why the *.mod file is being created if the linter is compiler based.

Screen Shot 2020-10-02 at 10 29 54 AM
JHenneberg commented 3 years ago

It is true. It is the extension moden fortran 2.2.1