Consider the program:
module pair
type :: pair
integer :: x, y
end type
type(pair) :: p = pair(1, 2)
end module
In the PSyIR symbol table for this module, the variable p is an UnsupportedFortranType. The reason is that the datatype of p does not pass the following check in the frontend:
|
if not isinstance( |
|
datatype, |
|
(ScalarType, ArrayType, UnsupportedType)): |
|
raise NotImplementedError |
It's not clear to me whether the behaviour is intentional or not. If we wanted to allow p to have an initial value then we'd have to allow allow DataTypeSymbol in the check and also allow Call as a valid node inside the DataSymbol.initial_value setter. Would this be somehow bad? It would permit some invalid Fortran, such as calling a function rather than a data constructor, but that could be potentially checked by the frontend or permitted under the assumption that the input code is valid fortran without leading to major issues?
I encountered this issue while trying to understand why the following program gives an error:
module pair
type :: pair
integer :: x, y
end type
type(pair) :: ps(1) = [pair(1, 2)]
end module
This program passes the frontend check (because it's an array not a DataTypeSymbol) but then hits the lack of support for Call in DataSymbol.initial_value. I'm trying to figure out what might be the right current solution for PSyclone:
- allow
Call nodes in initial values, or
- disallow initial values for derived types.
Consider the program:
In the PSyIR symbol table for this module, the variable
pis anUnsupportedFortranType. The reason is that the datatype ofpdoes not pass the following check in the frontend:PSyclone/src/psyclone/psyir/frontend/fparser2.py
Lines 2207 to 2210 in 2c73638
It's not clear to me whether the behaviour is intentional or not. If we wanted to allow
pto have an initial value then we'd have to allow allowDataTypeSymbolin the check and also allowCallas a valid node inside theDataSymbol.initial_valuesetter. Would this be somehow bad? It would permit some invalid Fortran, such as calling a function rather than a data constructor, but that could be potentially checked by the frontend or permitted under the assumption that the input code is valid fortran without leading to major issues?I encountered this issue while trying to understand why the following program gives an error:
This program passes the frontend check (because it's an array not a
DataTypeSymbol) but then hits the lack of support forCallinDataSymbol.initial_value. I'm trying to figure out what might be the right current solution for PSyclone:Callnodes in initial values, or