mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #2124 from chriseth/sol_conversionErrors
Improved type conversion error messages.
This commit is contained in:
commit
c447245cc5
42
AST.cpp
42
AST.cpp
@ -410,7 +410,14 @@ void InheritanceSpecifier::checkTypeRequirements()
|
|||||||
BOOST_THROW_EXCEPTION(createTypeError("Wrong argument count for constructor call."));
|
BOOST_THROW_EXCEPTION(createTypeError("Wrong argument count for constructor call."));
|
||||||
for (size_t i = 0; i < m_arguments.size(); ++i)
|
for (size_t i = 0; i < m_arguments.size(); ++i)
|
||||||
if (!m_arguments[i]->getType()->isImplicitlyConvertibleTo(*parameterTypes[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
|
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."));
|
BOOST_THROW_EXCEPTION(createTypeError("Wrong argument count for modifier invocation."));
|
||||||
for (size_t i = 0; i < m_arguments.size(); ++i)
|
for (size_t i = 0; i < m_arguments.size(); ++i)
|
||||||
if (!m_arguments[i]->getType()->isImplicitlyConvertibleTo(*(*parameters)[i]->getType()))
|
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()
|
void EventDefinition::checkTypeRequirements()
|
||||||
@ -782,9 +796,18 @@ void FunctionCall::checkTypeRequirements(TypePointers const*)
|
|||||||
{
|
{
|
||||||
// call by positional arguments
|
// call by positional arguments
|
||||||
for (size_t i = 0; i < m_arguments.size(); ++i)
|
for (size_t i = 0; i < m_arguments.size(); ++i)
|
||||||
if (!functionType->takesArbitraryParameters() &&
|
if (
|
||||||
!m_arguments[i]->getType()->isImplicitlyConvertibleTo(*parameterTypes[i]))
|
!functionType->takesArbitraryParameters() &&
|
||||||
BOOST_THROW_EXCEPTION(m_arguments[i]->createTypeError("Invalid type for argument in function call."));
|
!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
|
else
|
||||||
{
|
{
|
||||||
@ -808,7 +831,14 @@ void FunctionCall::checkTypeRequirements(TypePointers const*)
|
|||||||
if (parameterNames[j] == *m_names[i]) {
|
if (parameterNames[j] == *m_names[i]) {
|
||||||
// check type convertible
|
// check type convertible
|
||||||
if (!m_arguments[i]->getType()->isImplicitlyConvertibleTo(*parameterTypes[j]))
|
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;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user