Records: multioperator WL: shape of iteration space differs
The following program fails:
struct Foo {
int[3] x;
int y;
};
int main()
{
foos = with {
([0] <= [i] < [1000]) : Foo{ [i,i,i], i };
} : genarray([1000], Foo{ [0,0,0], 0 });
foos.x = { [i] -> _add_SxV_(1, foos[i].x) };
return foos[0].y;
}
Assertion "SHcompareShapes (iter_shp, ret_iter_shp)" failed at /home/jordy/sac2c/src/libsac2c/wltransform/wltransform.c:2533 -- multioperator WL: shape of iteration space differs
I believe this happens because x
is a vector but y
is a scalar.
shape(foos.x) = [1000, 3]
shape(foos.y) = [1000]
I have no idea if this can be fixed or whether it is a conceptual problem. Perhaps only the common prefix / outer shape ([1000]) should be equal? Likely that also requires changes in other places though...
Changing x
into a scalar makes the program compile:
struct Bar {
int x;
int y;
};
int main()
{
bars = with {
([0] <= [i] < [1000]) : Bar{ i, i };
} : genarray([1000], Bar{ 0, 0 });
bars.x = { [i] -> _add_SxS_(1, bars[i].x) };
return bars[0].y;
}