The following code,
var x: [1..10] real = 1;
var y: [1..10] real = 2;
var z: [1..11] real = 3;
x = y + z ;
writeln(x);
compiles and runs, and prints
5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0 5.0
But I am summing two arrays, y and z, with different shapes. Is this allowed by the language, or is the compiler overlooking something?
Cheers, Nelson
Hi Nelson —
This is not permitted by the language but, unfortunately, does not result in an error in the implementation today. It's a longstanding and unfortunate bug that is a result of our implementation of parallel zippered iteration: zippered forall loops with size mismatches can silently drop iterations on the floor · Issue #11428 · chapel-lang/chapel · GitHub
Note that it is also specific to the 'leader' expression (in this case 'x') being smaller than the followers. If you were to put 'z' first, you would get an execution-time error due to the fact that 'x' and 'y' don't have enough elements (ATO):
var x: [1..10] real = 1;
var y: [1..10] real = 2;
var z: [1..11] real = 3;
z = x + y ;
writeln(x);
The core of the issue is that our current framework does not notice the reverse case, when a 'follower' expression has too few elements.
-Brad
hi Brad: many thanks for the clarification. This is a minor issue at any rate.
Cheers Nelson.