Skip to content

StructureType.datatype can return an ArrayType with an ArrayType intrinsic. #3415

@LonelyCat124

Description

@LonelyCat124

the result of this section:

        # Walk down the structure, collecting information on any array slices
        # as we go.
        while isinstance(cursor, (StructureMember, StructureReference)):
            cursor = cursor.member
            if isinstance(cursor_type, ArrayType):
                cursor_type = cursor_type.intrinsic
            if isinstance(cursor_type, DataTypeSymbol):
                cursor_type = cursor_type.datatype
            if not isinstance(cursor_type, (UnresolvedType, UnsupportedType)):
                # Once we've hit an Unresolved/UnsupportedType the cursor_type
                # will remain set to that as we can't do any better.
                cursor_type = cursor_type.components[
                    cursor.name.lower()].datatype
            try:
                cursor_shape = _get_cursor_shape(cursor, cursor_type)
            except NotImplementedError:
                return UnresolvedType()
            if cursor_shape:
                if shape:
                    raise NotImplementedError(
                        f"Array of arrays not supported: the ultimate member "
                        f"'{cursor.name}' of the StructureAccess represents "
                        f"an array but other array notation is present in the "
                        f"full access expression: '{self.debug_string()}'")
                shape = cursor_shape

is Array<Scalar<REAL, UNDEFINED>, shape=[10, 10]> (for the datatype accessed in tests/psyir/transformations/intrinsics/array_reduction_base_trans_test.py::test_structure_error , and then the code does

        if shape:
            return ArrayType(cursor_type, shape)

resulting in the ArrayType datatype.
From discussion in #3373 we should never get an ArrayType with an ArrayType intrinsic so this is unintended and needs to be updated/fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions