PSyclone icon indicating copy to clipboard operation
PSyclone copied to clipboard

Potential problem with array mixin _get_effective_shape

Open hiker opened this issue 2 years ago • 2 comments

I was just adding tests, when I had crash. Cause:

    def _get_effective_shape(self):
...
       for idx_expr in self.indices:
            if isinstance(idx_expr, Range):
                shape.append(_num_elements(idx_expr))

            elif isinstance(idx_expr, Reference):
                dtype = idx_expr.datatype
                if dtype.shape:
   

This function is called from array_reference.datatype, with the content of map_adspc1_field_a(:,cell).

When working on the 2nd index, cell is a reference, but it's not an array and has no shape, so the test if dtype.shape just crashes.

I can work around this problem (by using array_reference.symbol.datatype instead of array_reference.datatype, and that's ok for me - but I am still wondering if this should be fixed in the code to avoid the crash?

hiker avatar Jan 25 '23 14:01 hiker

Oops, that's a bit of an error :-( Yes, we should check that the Reference is an array before looking at its shape.

arporter avatar Jan 25 '23 16:01 arporter

Fix is relatively straightforward - just use SIZE if we don't have an ArrayMixin. However, I've also found a bug in the validation of ArrayAssignment2LoopsTrans that I need to address.

arporter avatar Aug 06 '24 13:08 arporter