Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using module within blocks marked as error #157

Open
hippalectryon-0 opened this issue Jul 16, 2024 · 1 comment
Open

Using module within blocks marked as error #157

hippalectryon-0 opened this issue Jul 16, 2024 · 1 comment

Comments

@hippalectryon-0
Copy link

As indicated in https://fortran-lang.org/learn/quickstart/variables/, modules can be used inside BLOCK:

module your_module
    implicit none
    integer :: n = 2
end module

program main
    implicit none
    real :: x

    block
        use your_module, only: n ! you can import modules within blocks
        real :: y ! local scope variable
        y = 2.0
        x = y ** n
        print *, y
    end block
    ! print *, y ! this is not allowed as y only exists during the block's scope
    print *, x  ! prints 4.00000000
end program

However the linter marks that as an error.

@smoothdeveloper
Copy link

Similarly the variable definition gives:

block
  real :: y
  ^-------- Specification statement is not allowed here
end block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants