Compiler error messages leads to wrong usage of const generics #91119
Labels
A-const-generics
Area: const generics (parameters and arguments)
A-diagnostics
Area: Messages for errors, warnings, and lints
C-bug
Category: This is a bug.
D-incorrect
Diagnostics: A diagnostic that is giving misleading or incorrect information.
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Hi, folks!
Misusing const generics generates errors messages that lead the user to a wrong usage of the feature, let's follow an example:
Given this very simple (and wrong) definition:
playground
The compiler generates this error message:
Following the compiler suggestion:
We have a new error:
Applying the suggestion:
Leads to a new error:
And applying again:
Leads the user to a not intuitive point:
Ideally, we should not guide the user to such a long and erroneous path, and give them the correct answer that may look like this:
The text was updated successfully, but these errors were encountered: