Skip to content

Bug: Macros break fortls. #486

@oxcrow

Description

@oxcrow

Describe the bug

I tried to create a macro ok() that checks if an error code ie is set and returns from the subroutine.

This was intended to reduce the amount of boiler plate required to do error checking.

However this breaks fortls.

  • Fortls can not find the module where the macro is used.
  • Fortls can not autocomplete / hover / go-to-def inside the module.
  • Fortls can not autocomplete / hover / go-to-def when using types / methods outside of the module.

To Reproduce

Not sure if this will reproduce the bug on your machine; but this is a minimal code to reproduce the error.

Create file main.F90

program X
    use A
    call B()
end program

Create file a.F90

! BUG: Using this macro causes fortls to break down
#define ok() if(ie/=0) then; return; end if;

! Suprisingly this works well.
! #define ok()

module A
    implicit none
contains
    subroutine B
    integer :: ie
    ie = 1
    ok()
    end subroutine
end module

Expected behavior
Why do macros break fortls?

  • If a macro exists fortls should ignore it.
  • Or allow the user to ignore them through configuration.

Screenshots & Animations

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions