mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Improved type conversion error messages.
This commit is contained in:
parent
c2a9419e49
commit
9865a612a4
42
AST.cpp
42
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;
|
||||
|
Loading…
Reference in New Issue
Block a user