fortls icon indicating copy to clipboard operation
fortls copied to clipboard

[BUG] kind keyword in variable declarations identified as not defined

Open gnikit opened this issue 1 year ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Description

When somewhere in a project one uses kind as a variable name, then in other places in variable declarations the kind keyword becomes underlined as an error: "object kind not found in scope" (as shown in the screenshot below).

Below is the code to reproduce the problem. if you rename the variable inside the program section from kind to kind_ the error highlighting inside the function disappears:


module test_module
    implicit none
    
contains

    function echo(num) result (res)
        implicit none
        ! the line below is treated as problematic, depending on the variable name inside the program test (if there is no variable named kind, no problem)
        integer (kind=4) :: res, num
        
        print *, num + 1 

        res = 0
    end function echo
    
end module test_module

program test
    use test_module
    implicit none
    ! try renaming kind to toggle behavior
    integer :: kind, res


    kind = 10
    res = echo(kind)

end program test

Screenshots

image

Expected Behaviour

Should not be reported as an error.

Version of Modern Fortran

v3.2.0

Version of Visual Studio Code

v1.69.2

Platform and Architecture

Linux

Additional Information

Linked to #173

gnikit avatar Jul 22 '22 07:07 gnikit