28790, "DanilaFe", "Dyno: promotion with 'out' formal isn't treated as promotion", "2026-05-08T00:31:02Z"
I ran into this with the following test program:
module ChapelBase {
enum iterKind { standalone, leader, follower };
operator =(ref lhs:int, const rhs:int) {}
operator =(ref lhs:real, const rhs:real) {}
}
module Main {
use ChapelBase;
record R {
}
proc R.chpl__promotionType() type do return int;
iter R.these() do yield 1;
proc foo(out x: int) { x = 10; return x; }
for i in foo(new R()) {}
}
I was shocked to see an error, which was "cannot iterate over int".
This seems to stem from the fact that we always treat out formals as matching in can-pass.cpp:
Notice that pasAsIs does not mark the formal as having been promoted. As a result, we treat the call as a scalar call, which is not semantically correct.