New Issue: Bug with overloaded return intents

18205, "dlongnecke-cray", "Bug with overloaded return intents", "2021-08-11T20:58:31Z"

In the following program, I expect assignment to var or const to select the overload of makeRec that returns by value. This is my understanding according to the spec: Choosing Return Intent Overloads Based on Calling Context

record rec { var x = 0; }

var gRec = new rec();

proc makeRec(): rec {
  writeln('proc makeRec(): rec');
  return new rec();
}

proc makeRec() ref: rec {
  writeln('proc makeRec() ref: rec');
  return gRec;
}

proc makeRec() const ref: rec {
  writeln('proc makeRec() const ref: rec');
  return gRec;
}

proc test() {
  writeln('T1: store in var');
  var x1 = makeRec();
  writeln();

  writeln('T2: store in ref');
  ref x2 = makeRec();
  writeln();

  writeln('T3: store in const ref');
  const ref x3 = makeRec();
  writeln();

  writeln('T4: store in const');
  const x4 = makeRec();
  writeln();

  writeln('T5: call without assignment');
  makeRec();
}
test();

For the T1 and T4 cases I would expect the value overload of makeRec to be selected, but the const ref overload is selected instead.

T1: store in var
proc makeRec() const ref: rec

T2: store in ref
proc makeRec() ref: rec

T3: store in const ref
proc makeRec() const ref: rec

T4: store in const
proc makeRec() const ref: rec

T5: call without assignment
proc makeRec(): rec