chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.78k stars 418 forks source link

`createArray` fails to resolve with an unhelpful message with non-nilable element types #25966

Open e-kayrakli opened 6 hours ago

e-kayrakli commented 6 hours ago
use BlockDist;

class C {}

var Arr = blockDist.createArray(1..10, unmanaged C);

writeln(Arr);

produces

$CHPL_HOME/modules/dists/BlockDist.chpl:1016: error: cannot default-initialize the array A because it has a non-nilable element type 'unmanaged C'

this is all about the internal implementation. createArray functions should check for the element type and produce a better error message for unsupported types. And/or we should try to support them.

bradcray commented 5 hours ago

Definitely agree with the "better error message" request. I'm not seeing how we could support this call though? (specifically, I don't think we should create objects for the user).

Did we ever create a createArray() overload that also took an initial value (or collection of initial values) for the elements? That'd be a different way to support these element types.