New Issue: bug: can't return A.domain by const ref

20389, "vasslitvinov", "bug: can't return A.domain by const ref", "2022-08-05T04:05:07Z"

The compiler issues error: illegal expression to return by ref for the following program:

proc getDom() const ref {
  return Locales.domain;   // error here
}

const ref x = getDom();

This error was introduced in #4899, however it was overly conservative and might now be duplicated by the lifetime checker.

The above program should compile. However, the following program should not:

proc getDom() const ref {
  var locArr: [1..3] int;
  return locArr.domain;   // error here
}

const ref x = getDom();

Tests: TBD.