New Issue: A confusing error "cannot assign" for a 'ref' task-private variable

17368, "vasslitvinov", "A confusing error "cannot assign" for a 'ref' task-private variable", "2021-03-08T06:28:36Z"

The following code:

var outerVar: int;

forall 1..2 with (ref myRef = outerVar) {
  myRef = 2;


produces an error cannot assign to const variable on the line myRef = 2;.

This is probably caused by the fact that outerVar itself is passed by default intent and so cannot have non-const refs to it. Even if so, the error should point to that directly, rather than waiting for an assignment.

If the assignment is not there, the error does point to the with-clause. However, it would be good to mention that the const variable is outerVar and it is const because of forall intents.

If, on the other hand, we add a ref intent for outerVar, the program compiles and executes as expected.