New Issue: Capturing 'const ref' argument as mutable 'ref' should be an error

19614, "arezaii", "Capturing 'const ref' argument as mutable 'ref' should be an error", "2022-04-07T16:50:08Z"

When capturing an argument that is passed by const ref, such as with varargs or tuples, if the argument is captured to a ref, the behavior is not well defined. In the case of the code below, we are implicitly copying the refs on return.

proc bar(paths: myRec ...?n) {
  ref refToArg = paths;

  return refToArg;

So the behavior is more like if the ref was a var but the deep copy happens at return instead of variable instantiation.

A future for this behavior is located in test/functions/varargs/stringVarargLeakByRef

See change test var decl from ref to var by arezaii · Pull Request #19357 · chapel-lang/chapel · GitHub and related issue What does it mean to return/yield a tuple by `ref`? · Issue #15973 · chapel-lang/chapel · GitHub