Branch: refs/heads/main
Revision: def068f
Author: vasslitvinov
Link: Defuturize: ref array formal can't accept iterable by vasslitvinov · Pull Request #20137 · chapel-lang/chapel · GitHub
Log Message:
Merge pull request #20137 from vasslitvinov/defuturize_arrArgXXX-promote
Defuturize: ref array formal can't accept iterable
This PR resolves three futures by asserting the following semantics.
A formal argument of an array type cannot accept an iterable, such as
a promoted expression, when the formal's intent is ref
or const ref
.
This includes the default and const
abstract intents.
The rationale is that a ref
formal requires an actual argument of the
same type. An iterable expression does not have an array type and there is
no underlying array to refernce.
To force creation of an array out of an iterable when passing the latter
to a formal argument, the formal argument must have an in
or const in
intent, see test/users/thom/arrArgIn-promote.chpl
.
Next steps, recorded in #20166: should a ref
formal accept
an array returned by a function with the default return intent?
What if it is a const ref
formal and/or
the function's return intent is const
?
For example:
proc writeArr(ref X) { // what if X has a const ref
intent?
writeln(X);
}
proc addEm() { // what if addEm() has a const
return intent?
return [1,2];
}
writeArr(addEm());
r: @mppf; discussed with @bradcray
Modified Files:
A test/users/thom/arrArg-fromFunction.bad
A test/users/thom/arrArg-fromFunction.chpl
A test/users/thom/arrArg-fromFunction.future
A test/users/thom/arrArg-fromFunction.good
R test/users/thom/arrArgBlank-promote.bad
R test/users/thom/arrArgBlank-promote.future
R test/users/thom/arrArgConst-promote.bad
R test/users/thom/arrArgConst-promote.future
R test/users/thom/arrArgRef-promote.bad
R test/users/thom/arrArgRef-promote.future
M test/users/thom/arrArgBlank-promote.chpl
M test/users/thom/arrArgBlank-promote.good
M test/users/thom/arrArgConst-promote.chpl
M test/users/thom/arrArgConst-promote.good
M test/users/thom/arrArgRef-promote.chpl
M test/users/thom/arrArgRef-promote.good
Compare: https://github.com/chapel-lang/chapel/compare/c95e18032591...def068f196de