fortls icon indicating copy to clipboard operation
fortls copied to clipboard

Renaming only imported statements yields incorrect results

Open gnikit opened this issue 2 years ago • 0 comments

Trying to rename localname in use rename_mod2, only : localname => originalname will rename localname in the use statement but not in the subsequent scopes and will erroneously rename originalname

module rename_mod1
real(8) :: var1
end module rename_mod1
!
module rename_mod2
use rename_mod1, only: renamed_var1 => var1
integer :: originalname
end module rename_mod2
!
subroutine test_rename_sub()
use rename_mod2, only : localname => originalname, renamed_var2 => renamed_var1
implicit none
!
localname = 4
renamed_var2 = 4    
end subroutine test_rename_sub

Additional MWE to consider; renaming tr does not propagate

module rename
contains
    subroutine test(a)
        print*,a
    end subroutine test
end module rename

program main
    use mod, tr => test
    call tr(2.0)
end program main

gnikit avatar Feb 23 '22 13:02 gnikit