[Chapel Merge] Allow remote variables to perform `init=` coercions

Branch: refs/heads/main
Revision: b0df85fb02c1f4185ea1330062957f73a96b3e3b
Author: DanilaFe
Link: Allow remote variables to perform `init=` coercions. by DanilaFe · Pull Request #25603 · chapel-lang/chapel · GitHub
Log Message:
Allow remote variables to perform init= coercions. (#25603)

Builds on Remote variables: execute initialization expression on the target locale by DanilaFe · Pull Request #25406 · chapel-lang/chapel · GitHub. Closes
Remote variable declarations don't support initializing arrays with scalars · Issue #25430 · chapel-lang/chapel · GitHub.

This PR ensures that remote variable declarations support cross-type
initialization via init=, such as when initializing an array with a
scalar:

on Locales.last var A: [1..10] int = 2;

Previously, remote variables required the type and the initialization
expression of a variable to strictly match. However, this isn't done
"normally", since we allow for init= coercions and other ways of
initializing variables. This PR adjusts this by changing the
type-and-value overload to explicitly use a typed temp (var temp: specifiedType = initExpr) which ensures that the standard init=
semantics applies.

Reviewed by @e-kayrakli -- thanks!

Testing

  • paratest
  • GPU test

Compare: Comparing 7216900c4a550cd80abc36a63a0a706eeba0ea81...22e44c7a76968c00897186b1aeba219387cde49c · chapel-lang/chapel · GitHub

Diff:
M modules/internal/ChapelRemoteVars.chpl
M test/variables/remote/array.chpl
M test/variables/remote/array.good
A test/variables/remote/coerce-record.chpl
A test/variables/remote/coerce-record.good
M test/variables/remote/init-on-target.chpl
M test/variables/remote/init-on-target.good
https://github.com/chapel-lang/chapel/pull/25603.diff