Adds an additional message to failing type conversions.

This commit is contained in:
Erik Kundt
2018-12-07 11:55:53 +01:00
parent 52ff3c9455
commit b2afb8cdda
8 changed files with 34 additions and 19 deletions
+4 -2
View File
@@ -1252,7 +1252,8 @@ void TypeChecker::endVisit(BinaryOperation const& _operation)
{
TypePointer const& leftType = type(_operation.leftExpression());
TypePointer const& rightType = type(_operation.rightExpression());
TypePointer commonType = leftType->binaryOperatorResult(_operation.getOperator(), rightType);
TypeResult result = leftType->binaryOperatorResult(_operation.getOperator(), rightType);
TypePointer commonType = result.get();
if (!commonType)
{
m_errorReporter.typeError(
@@ -1262,7 +1263,8 @@ void TypeChecker::endVisit(BinaryOperation const& _operation)
" not compatible with types " +
leftType->toString() +
" and " +
rightType->toString()
rightType->toString() +
(!result.message().empty() ? ". " + result.message() : "")
);
commonType = leftType;
}