Skip to content

Type patterns for records: use _dim_A_ and _shape_A_

Jordy Aaldering requested to merge 2407-type-pattern-record-dim-shape into develop

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.

Edited by Jordy Aaldering

Merge request reports