Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1 View

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
0 Kudos
1 Reply
Highlighted
Employee
1 View

Thank you for reporting this

Thank you for reporting this defect and for the convenient reproducer. I escalated it to Development.

(Internal tracking id: DPD200420015)

0 Kudos