fortran-lang / fortls

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

incorrect indication with `block` as variable or label #292

Open folk85 opened 1 year ago

folk85 commented 1 year ago

Describe the bug If we define the label or variable with name block, then it would indicate end of routine as incorrect end.

To Reproduce If I use the following command fortls --debug_filepath test_rename_block.f90 --debug_rootpath . --debug_full_result --debug_log I get info:

DEBUG:fortls.constants:REQUEST None None
INFO:fortls.constants:fortls - Fortran Language Server 0.1.dev986+g8f11b57 Initialized

The example of code:

module test_rename_block
    implicit none
contains

    subroutine block_test01()
        integer :: i 
        block: do i = 1, 1 
            write(*, *) "use label with name block : ", i  
        end do block
    end subroutine block_test01

    subroutine block_test02()
        integer :: block 
        do block = 1, 1 
            write(*, *) "use index name block :", block 
        end do
    end subroutine block_test02

end module test_rename_block

program driver
    use test_rename_block 
    implicit none
    call block_test01()
    call block_test02()
end program driver

Expected behavior If we use variable or label name as block the fortls won't expect end block part and must show end of subroutine/function correctly.

Screenshots & Animations image

Setup information (please complete the following information):

byornski commented 1 month ago

Can confirm this bug. We've hit this with some code with variable names like block_data and it breaks the scoping for every routine after this point.