Support secondary notes and possible-cause hints for diagnostics #1407
Description
In some cases, the cause of an error message may not be localized to the point where the error is generated. It could have multiple causes or related aspects in different parts of the program. It would be helpful if the compiler could direct the user to these parts so they could get more context or consider changing them.
For example:
let f = x -> x * x;
let _ = f([2]);
Here an error message for the expression [2]
is generated, saying that it doesn't support arithmetic operators. This is correct, but the cause of this requirement is the use of the *
operator in the lambda.
Unfortunately, the compiler isn't capable of generating a diagnostic inside the previous statement, because the diagnostic range must be relative to the current statement. This limitation would need to be removed to support this.