External Issue: defining arrays as borrowed gives poor user feedback from chpl

16860, “ahysing”, “defining arrays as borrowed gives poor user feedback from chpl.”, “2020-12-14T07:34:17Z”

when defining an array in a record, and not explicitly setting the array domain one ends up with an error AST-LOO-XPR-0201

Summary of Problem

I have created my own key comparator for sorting. My can sort one array based on values in a diffrent array fScore.

I want to be explicit that fScore is an array. the array is owned outside the record, and will outlive the record. The domain of the array is defined in a different scope, and is not available.

One expects the program to compile, but this causes error listed below. This error is rather poor on what causes the problem.

internal error: AST-LOO-XPR-0201 chpl version 1.23.0

Internal errors indicate a bug in the Chapel compiler ("It's us, not you"),
and we're sorry for the hassle.  We would appreciate your reporting this bug --
please see https://chapel-lang.org/bugs.html for instructions.  In the meantime,
the filename + line number above may be useful in working around the issue.

I are two solutions to this problem.

Removed borrowed

On line 2. By changing the record type from var fScore : borrowed [..] real; to var fScore : [..] real; the program compiles without an error.

Skip the array type

On line 2. By changing the record type from var fScore : borrowed [..] real; to var fScore; the program compiles without an error.

Steps to Reproduce

Source Code:

In chapel file FScoreComparator.chpl

record FScoreComparator {
  var fScore :  borrowed [..] real;
  proc init(fScore : borrowed [..] real) {
    this.fScore = fScore;
  }
}

proc FScoreComparator.key(i) {
  var D = this.fScore.domain;
  if D.contains(i) then
    return this.fScore[i];
  else
    return max(real);
}

Compile command:
chpl FScoreComparator.chpl