From 033fc0cb1acab770e25f54d7ee2d50be994a4e45 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 11 Jul 2017 21:08:39 +0100 Subject: [PATCH] Include types in explicit conversion error message --- Changelog.md | 1 + libsolidity/analysis/TypeChecker.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 62b529426..e64a8feaa 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,7 @@ Features: * Inline Assembly: Show useful error message if trying to access calldata variables. * Inline Assembly: Support variable declaration without initial value (defaults to 0). * Type Checker: Disallow value transfers to contracts without a payable fallback function. + * Type Checker: Include types in explicit conversion error message. * Type Checker: Raise proper error for arrays too large for ABI encoding. Bugfixes: diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 29db7441e..23f01752b 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1364,7 +1364,14 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) // (data location cannot yet be specified for type conversions) resultType = ReferenceType::copyForLocationIfReference(argRefType->location(), resultType); if (!argType->isExplicitlyConvertibleTo(*resultType)) - m_errorReporter.typeError(_functionCall.location(), "Explicit type conversion not allowed."); + m_errorReporter.typeError( + _functionCall.location(), + "Explicit type conversion not allowed from \"" + + argType->toString() + + "\" to \"" + + resultType->toString() + + "\"." + ); } _functionCall.annotation().type = resultType; _functionCall.annotation().isPure = isPure;