aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-06-09 17:57:06 +0800
committerchriseth <c@ethdev.com>2015-06-09 17:57:52 +0800
commit9865a612a434a2051630cf153d18e68029b326e7 (patch)
treede3b4b6ff4254fe47b6e48f1efc456b04daf357f /AST.cpp
parentc2a9419e495e931a825e8146aec49ffc34e44954 (diff)
downloaddexon-solidity-9865a612a434a2051630cf153d18e68029b326e7.tar.gz
dexon-solidity-9865a612a434a2051630cf153d18e68029b326e7.tar.zst
dexon-solidity-9865a612a434a2051630cf153d18e68029b326e7.zip
Improved type conversion error messages.
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp42
1 files changed, 36 insertions, 6 deletions
diff --git a/AST.cpp b/AST.cpp
index 4c7168af..acb7b50c 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -410,7 +410,14 @@ void InheritanceSpecifier::checkTypeRequirements()
BOOST_THROW_EXCEPTION(createTypeError("Wrong argument count for constructor call."));
for (size_t i = 0; i < m_arguments.size(); ++i)
if (!m_arguments[i]->getType()->isImplicitlyConvertibleTo(*parameterTypes[i]))
- BOOST_THROW_EXCEPTION(createTypeError("Invalid type for argument in constructer call."));
+ BOOST_THROW_EXCEPTION(m_arguments[i]->createTypeError(
+ "Invalid type for argument in constructor call. "
+ "Invalid implicit conversion from " +
+ m_arguments[i]->getType()->toString() +
+ " to " +
+ parameterTypes[i]->toString() +
+ " requested."
+ ));
}
TypePointer StructDefinition::getType(ContractDefinition const*) const
@@ -592,7 +599,14 @@ void ModifierInvocation::checkTypeRequirements(vector<ContractDefinition const*>
BOOST_THROW_EXCEPTION(createTypeError("Wrong argument count for modifier invocation."));
for (size_t i = 0; i < m_arguments.size(); ++i)
if (!m_arguments[i]->getType()->isImplicitlyConvertibleTo(*(*parameters)[i]->getType()))
- BOOST_THROW_EXCEPTION(createTypeError("Invalid type for argument in modifier invocation."));
+ BOOST_THROW_EXCEPTION(m_arguments[i]->createTypeError(
+ "Invalid type for argument in modifier invocation. "
+ "Invalid implicit conversion from " +
+ m_arguments[i]->getType()->toString() +
+ " to " +
+ (*parameters)[i]->getType()->toString() +
+ " requested."
+ ));
}
void EventDefinition::checkTypeRequirements()
@@ -782,9 +796,18 @@ void FunctionCall::checkTypeRequirements(TypePointers const*)
{
// call by positional arguments
for (size_t i = 0; i < m_arguments.size(); ++i)
- if (!functionType->takesArbitraryParameters() &&
- !m_arguments[i]->getType()->isImplicitlyConvertibleTo(*parameterTypes[i]))
- BOOST_THROW_EXCEPTION(m_arguments[i]->createTypeError("Invalid type for argument in function call."));
+ if (
+ !functionType->takesArbitraryParameters() &&
+ !m_arguments[i]->getType()->isImplicitlyConvertibleTo(*parameterTypes[i])
+ )
+ BOOST_THROW_EXCEPTION(m_arguments[i]->createTypeError(
+ "Invalid type for argument in function call. "
+ "Invalid implicit conversion from " +
+ m_arguments[i]->getType()->toString() +
+ " to " +
+ parameterTypes[i]->toString() +
+ " requested."
+ ));
}
else
{
@@ -808,7 +831,14 @@ void FunctionCall::checkTypeRequirements(TypePointers const*)
if (parameterNames[j] == *m_names[i]) {
// check type convertible
if (!m_arguments[i]->getType()->isImplicitlyConvertibleTo(*parameterTypes[j]))
- BOOST_THROW_EXCEPTION(createTypeError("Invalid type for argument in function call."));
+ BOOST_THROW_EXCEPTION(m_arguments[i]->createTypeError(
+ "Invalid type for argument in function call. "
+ "Invalid implicit conversion from " +
+ m_arguments[i]->getType()->toString() +
+ " to " +
+ parameterTypes[i]->toString() +
+ " requested."
+ ));
found = true;
break;