Quantcast
Viewing all articles
Browse latest Browse all 415

Nested blocks prohibit function assignment

When nesting block statements into each other, it is no longer possible to access the result value of an outer function.Consider

program nestBlock

   implicit none

   contains
      integer function test() result(Res)
         block
            block
               Res = 1
            end block
         end block
      end function
end program

This leads to error #7816: Invalid assignment to function result of external procedure.
The error occurs regardless of whether a result variable is defined or the function name is used by itself. Assignment works for one single block, but as soon as the second level starts, the result can no longer be written to.
Compiler: Visual Fortran Compiler 17.0.2.187


Viewing all articles
Browse latest Browse all 415

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>