I try to return a reference to a slice of an array, but I get the following compile-time error (where the violation line is in slice
test.chpl: 9: error: illegal expression to return by ref
Returning a full array works fine, as does a link to a slice in the main program.
Is there a proper way to return a ref to a slice? Thanks in advance!
record R {
var A : [0.. #10] int;
proc full() ref {
return A;
}
proc slice() ref {
return A[0.. #5];
}
}
var r : R;
ref x1 = r.full();
ref x2 = r.slice();
ref x3 = x1[0.. #5];
For completeness only:
chpl Version 1.16.0 preview (2659cc6)
source
share