diff options
author | Gav Wood <g@ethdev.com> | 2015-06-09 22:19:02 +0800 |
---|---|---|
committer | Gav Wood <g@ethdev.com> | 2015-06-09 22:19:02 +0800 |
commit | c447245cc5c8f50d76d927f32ba68ccc2c981627 (patch) | |
tree | 7d0a55b4bf0f44e1c7238b45504cdc2b603b7d90 | |
parent | 99fed1aba7eb2af17d7a75b5578f73fa969b46df (diff) | |
parent | 9865a612a434a2051630cf153d18e68029b326e7 (diff) | |
download | dexon-solidity-c447245cc5c8f50d76d927f32ba68ccc2c981627.tar dexon-solidity-c447245cc5c8f50d76d927f32ba68ccc2c981627.tar.gz dexon-solidity-c447245cc5c8f50d76d927f32ba68ccc2c981627.tar.bz2 dexon-solidity-c447245cc5c8f50d76d927f32ba68ccc2c981627.tar.lz dexon-solidity-c447245cc5c8f50d76d927f32ba68ccc2c981627.tar.xz dexon-solidity-c447245cc5c8f50d76d927f32ba68ccc2c981627.tar.zst dexon-solidity-c447245cc5c8f50d76d927f32ba68ccc2c981627.zip |
Merge pull request #2124 from chriseth/sol_conversionErrors
Improved type conversion error messages.
-rw-r--r-- | AST.cpp | 42 |
1 files changed, 36 insertions, 6 deletions
@@ -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; |