Another strange one with parameterized derived types: the following simple code results in a compiler error, incorrectly in my opinion. But simply uncommenting the unrelated lines 17-26 makes the code compile ok:
module m implicit none private type, public :: t(n) private integer, len :: n = 1 integer :: m_x(n) contains procedure, pass(this), public :: x => get_t_x end type t contains !subroutine load_t_x(this, dat) ! ! class(t(*)), intent(inout) :: this ! integer(kind=kind(this%m_x)), intent(in) :: dat(:) ! ! this%m_x = dat ! ! return ! !end subroutine load_t_x function get_t_x(this) result(retval) class(t(*)), intent(in) :: this !.. integer(kind=kind(this%m_x)) :: retval(this%n) retval = this%m_x return end function get_t_x end module m
The compiler output is:
------ Build started: Project: p, Configuration: Debug|x64 ------ Compiling with Intel(R) Visual Fortran Compiler XE 15.0.2.179 [Intel(R) 64]... m.f90 C:\..\m.f90(32): error #6160: This component is not a field of the encompassing structure. [N] compilation aborted for C:\..\m.f90 (code 1)