Closes #2407 (closed)
When type patterns are being applied to user-defined types we assume that dim
and shape
are overloaded for those types.
We then apply those functions in the generated code, instead of the primitives _dim_A_
and _shape_A_
because these functions cannot exist for such user-defined types.
However in the case of records we actually expand these into their separate arguments, to which these primitive functions CAN be applied.
struct Foo { int x; int y; };
int bar(struct Foo[*] foos) {
_shape_A_(foos);
}
Becomes:
struct Foo { int x; int y; };
int bar(int[*] foos_x, int[*] foos_y) {
_shape_A_(foos_x);
}
So if we find a type pattern on a record, we should apply the primitive functions instead.