Closed arporter closed 5 years ago
OK, this was a fun one. The following cut down example still failed. However, if I removed the ::
in the type declaration then it worked.
TYPE(FLD) :: sf_t_rnf
CONTAINS
integer FUNCTION sbc_rnf_alloc()
END FUNCTION sbc_rnf_alloc
The reason for this is that fparser was matching `type(fld) :: sf_t_rnf as the beginning of a derived_type_definition and then matching subsequent lines i.e.
type :: y
contains
integer function x()
end function x
end type y
and so tried to parse contains and the subsequent function as content to the type declaration. At some point one of the matches failed as it got strange unexpected content.
The first line was matching as the implementation of Derived_Type_Stmt r430 did not check for invalid content between TYPE
and ::
i.e. (FLD)
was ignored.
If we add a check for invalid content in the match
method of Derived_Type_Stmt
then all is well.
Created branch derived_type_stmt_error
pr #133 has been merged to master. Closing this issue.
This problem is triggered by the following Fortran:
fparser2 falls over while attempting to match the function statement:
Strangely, if I remove either the
TYPE(FLD)
declaration or theinteger
qualifier on the function statement then fparser2 is happy.