You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When variables are declared within a "module procedure" scope they seem to remain in the parsers "memory" beyond the "end procedure" statement.
If the same name is used within a subsequent module procedure it is marked as an error (integer :: i in sub2) (duplicate variable), if the same name is used within a subroutine or function (sub3) a warning is displayed on hovering that the variable is going to mask a variable in the parent scope.
module mymod
interface
modulesubroutinesub1endsubroutinemodulesubroutinesub2endsubroutine
end interface
end module
submodule (mymod) submod
contains
module procedure sub1
implicit noneinteger:: i
i =1write(*,*) i
end procedure
module procedure sub2
implicit noneinteger:: i
i =2write(*,*) i
end procedure
modulesubroutinesub3implicit noneinteger:: i
endsubroutine
end submodule
program test
use mymod
call sub1
call sub2
end program
The code works fine and the compiler fails if the declaration of i in `sub2 is removed.
I checked the parse_fortran.py file and as far as I can tell one could either pretend those module procedures are a standalone unit (create a new_scope thingy) or --- which would probably be a more consistent solution --- find a way to connect them to their declaration in the ancestor modules interfaced where "their new scope" might be already declared(?).
I thought about something like this and noticed that I am in way over my head trying to figure this one out.
MODPROC_REGEX=re.compile(r'[ ]*MODULE PROCEDURE[ ]+([a-z0-9_]+)',re.I)
END_MODPROC_WORD=r'PROCEDURE'
...
read_modproc_def ...
return'modproc', name
...
elifobj_type='modproc'#(access scope declared in a different file with parent (sub)module to add local variables)
The text was updated successfully, but these errors were encountered:
When variables are declared within a "module procedure" scope they seem to remain in the parsers "memory" beyond the "end procedure" statement.
If the same name is used within a subsequent module procedure it is marked as an error (
integer :: i
insub2
) (duplicate variable), if the same name is used within a subroutine or function (sub3
) a warning is displayed on hovering that the variable is going to mask a variable in the parent scope.The code works fine and the compiler fails if the declaration of
i
in `sub2 is removed.I checked the parse_fortran.py file and as far as I can tell one could either pretend those module procedures are a standalone unit (create a new_scope thingy) or --- which would probably be a more consistent solution --- find a way to connect them to their declaration in the ancestor modules interfaced where "their new scope" might be already declared(?).
I thought about something like this and noticed that I am in way over my head trying to figure this one out.
The text was updated successfully, but these errors were encountered: