chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.75k stars 410 forks source link

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

Open e-kayrakli opened 2 weeks ago

e-kayrakli commented 2 weeks ago

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.