24886, "e-kayrakli", "[Bug]: Using a class instance with a 'reduce' intent doesn't resolve", "2024-04-18T23:43:32Z"
Summary of Problem
Using a class instance with a reduce
intent doesn't resolve. I think we need to make some adjustments in the reduction implementation.
Description:
$CHPL_HOME/modules/internal/ChapelReduce.chpl:111: In function 'chpl__sumType':
$CHPL_HOME/modules/internal/ChapelReduce.chpl:116: error: cannot default-initialize x: owned MyType
$CHPL_HOME/modules/internal/ChapelReduce.chpl:130: error: use here prevents split-init
note: non-nilable class type 'borrowed MyType' does not support default initialization
note: Consider using the type managed _owned(MyType)? instead
$CHPL_HOME/modules/internal/ChapelReduce.chpl:142: called as chpl__sumType(type eltType = owned MyType) from initializer
$CHPL_HOME/test/gpu/native/reduction/degenAccumulate.chpl:17: called as SumReduceScanOp.init(l: chpl_LocalSpinlock, eltType: owned MyType, value: int(64))
Is this a blocking issue with no known work-arounds?
no
Steps to Reproduce
Source Code:
class MyType {
var x: int;
}
operator MyType.+(first, second) {
return first.x + second.x;
}
var obj = new MyType();
forall i in 1..10 with (+ reduce obj) {
obj += new MyType(i);
}
writeln(obj);
Compile command:
chpl foo.chpl
Configuration Information
Shouldn't matter.