Because when you comment out neg
, essentially you are just using the inherited method diff
. “A Fortran extended type inherits all of the type parameters, components and nonoverridden, nonfinal procedure bindings from its parent type” (Extensible derived types (Fortran 2003) - IBM Documentation). But when you do generic :: operator(-) => diff, neg
, the generic binding is not inherited and you will have to define your operator(-)
for the extended type as well. I suggest you read @FortranFan’s answer in Custom operators in extended type - Help - Fortran Discourse (fortran-lang.discourse.group).