Skip to content

Should arrays-of-arrays support promotion across nestings? #26848

Open
@bradcray

Description

@bradcray

While working on some array-of-array code recently, I found myself wondering which sorts of promotions we think ought to work in Chapel for arrays-of-arrays:

// Given:
var A: [1..3] [1..3] [1..3] real;

// This works because A and D have the same type/shape
var D: [1..3] [1..3] [1..3] real;
A = D;

// this works because C.type == A.eltType, so it's a normal promotion
var C: [1..3] [1..3] real;
A = C;


// this seems like perhaps it should work, but it doesn't.  We get "cannot iterate over values of type real(64)
A = 1.2;                        // error: cannot iterate over values of type real(64)

// this also seems like it could arguably work as a promotion over the second level of A, but it similarly doesn't
var B: [1..3] real;
A = B;                          // error: cannot iterate over values of type real(64)

Similarly, should one be able to call sin(A) or A + D and get an array-of-array-of-array-of-real result?

In essence, this issue asks "Should promotion be recursively considered in array-of-array situations, or restricted only to the outermost array, as it currently seems to be?"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions