Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ast: improve error message when inheritance is used without ref #3570

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/dev/flang/ast/AstErrors.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,12 @@ else if (frmlT.compareTo(Types.resolved.t_unit) == 0)
}
else
{
remedy = "To solve this, you could change the type of the target " + ss(target) + " to " + s(actlT) + " or convert the type of the assigned value to " + s(frmlT) + ".\n";
remedy = !frmlT.isRef() && !actlT.isGenericArgument() && !frmlT.isGenericArgument() && actlT.feature().inheritsFrom(frmlT.feature()) ?
"To solve this you could:\n" + //
" • make " + s(frmlT) + " a reference by adding the " + st("ref")+ " keyword, so all its heirs can be used in place of it,\n" + //
" • change the type of the target " + ss(target) + " to " + s(actlT) + ", or\n" + //
" • convert the type of the assigned value to " + s(frmlT) + "."
: "To solve this, you could change the type of the target " + ss(target) + " to " + s(actlT) + " or convert the type of the assigned value to " + s(frmlT) + ".\n";
}
actlFound = "actual type found : " + s(actlT);
valAssigned = "for value assigned : " + s(value) + "\n";
Expand Down