chapel icon indicating copy to clipboard operation
chapel copied to clipboard

Wrong error message while accessing an array field on a nilable without postfix-`!`

Open e-kayrakli opened this issue 10 months ago • 0 comments

Consider the following erroneous code:

class MyClass {
  var FieldArr: [1..10] int;
}

var c: owned MyClass?;

c = new MyClass();

writeln(c.FieldArr[3]);  // `c` needs to be `c!`

The code compiles if you use a postfix-! on c. This is expected, but today, I am getting the following error on the problematic line instead:

$CHPL_HOME/nilableField.chpl:9: error: unresolved call 'owned MyClass?.FieldArr[3]'
$CHPL_HOME/nilableField.chpl:2: note: this candidate did not match: MyClass.FieldArr
$CHPL_HOME/nilableField.chpl:9: note: because call includes 1 argument
$CHPL_HOME/nilableField.chpl:2: note: but function can only accept 0 arguments

which is misleading as it ostensibly complains about FieldArr[3] part.

e-kayrakli avatar Apr 26 '24 16:04 e-kayrakli