chapel
chapel copied to clipboard
Provide better error messages for `operator`s
Here are some cases that can use better error messages:
1. proc type
nature of operator
s could be incorporated into error messages
record myRec {
var x: int;
operator +(a) {return x+a; }
}
var r: myRec;
writeln(r+1);
says
error: unresolved call '+(myRec, 1)'
I'd like our compiler to remind me that an operator
is a type
method where the receiver is a type. I don't know how it thinks x
is of type myRec
either, but there must be some confusion about the receiver, I think
2. operator
s with wrong number of arguments simply aren't resolved and dropped
but they should cause error messages, because their existence probably indicates a not-so-innocent mistake in code that can turn up as more difficult errors:
record myRec {
var x: int;
// I wrote the following which resulted in unresolved call later,
operator +(a) {return a; }
// ... b/c what I needed was:
operator +(a, b:int) {return b; }
// I could also write:
operator +(a,b,c) {return a+b+c; }
}
var r: myRec;
writeln(r+1);
The first and the last methods there should have been caught by the compiler. I think they should be errors.