Better error message when trying to call things that are not functions

This commit is contained in:
Kamil Śliwak
2023-04-04 17:30:37 +02:00
parent 293690e5a4
commit a019f400d0
13 changed files with 46 additions and 8 deletions
+5 -1
View File
@@ -2847,7 +2847,11 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
}
default:
m_errorReporter.fatalTypeError(5704_error, _functionCall.location(), "Type is not callable");
m_errorReporter.fatalTypeError(
5704_error,
_functionCall.location(),
capitalized(Type::categoryName(expressionType->category())) + " is not callable."
);
// Unreachable, because fatalTypeError throws. We don't set kind, but that's okay because the switch below
// is never reached. And, even if it was, SetOnce would trigger an assertion violation and not UB.
funcCallAnno.isPure = argumentsArePure;