Real and imaginary parts of complex number

Seeing this post I thought renaming the function would likely eliminate the gfortran error where it fails saying it is recursive but it did not:

program testit
implicit none
complex :: x
real    :: img
img(x) = x%im
   write (*, *) img((1.0,3.0) + (2.0,4.0))
end program testit
gfortran main.f90
main.f90:5:9:

    5 | img(x) = x%im
      |         1
Error: Statement function at (1) is recursive

So

  • nagfor runs
  • ifx/ifort ICE
  • gfortran produces “recursive” error

so far. Nice to know nagfor works; as two compiler failures made me question if the case was standard although I could not think of a reason
it was not.