diff options
author | Christian <c@ethdev.com> | 2014-11-04 22:29:08 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-11-06 09:22:24 +0800 |
commit | 4b6c42231595cd8a53327656db4ac22db70960d5 (patch) | |
tree | 790647ab906069c21bf1f1005273d407b188c186 /AST.cpp | |
parent | 29c9a7aed90e415bcf5eebb16228336576643a3f (diff) | |
download | dexon-solidity-4b6c42231595cd8a53327656db4ac22db70960d5.tar.gz dexon-solidity-4b6c42231595cd8a53327656db4ac22db70960d5.tar.zst dexon-solidity-4b6c42231595cd8a53327656db4ac22db70960d5.zip |
More information for type expectation errors.
Diffstat (limited to 'AST.cpp')
-rw-r--r-- | AST.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -347,9 +347,11 @@ void ExpressionStatement::checkTypeRequirements() void Expression::expectType(Type const& _expectedType) { checkTypeRequirements(); - if (!getType()->isImplicitlyConvertibleTo(_expectedType)) - BOOST_THROW_EXCEPTION(createTypeError("Type not implicitly convertible to expected type.")); - //@todo provide more information to the exception + const Type& type = *getType(); + if (!type.isImplicitlyConvertibleTo(_expectedType)) + BOOST_THROW_EXCEPTION(createTypeError("Type " + type.toString() + + " not implicitly convertible to expected type " + + _expectedType.toString() + ".")); } void UnaryOperation::checkTypeRequirements() @@ -373,14 +375,18 @@ void BinaryOperation::checkTypeRequirements() else if (m_left->getType()->isImplicitlyConvertibleTo(*m_right->getType())) m_commonType = m_right->getType(); else - BOOST_THROW_EXCEPTION(createTypeError("No common type found in binary operation.")); + BOOST_THROW_EXCEPTION(createTypeError("No common type found in binary operation: " + + m_left->getType()->toString() + " vs. " + + m_right->getType()->toString())); if (Token::isCompareOp(m_operator)) m_type = make_shared<BoolType>(); else { m_type = m_commonType; if (!m_commonType->acceptsBinaryOperator(m_operator)) - BOOST_THROW_EXCEPTION(createTypeError("Operator not compatible with type.")); + BOOST_THROW_EXCEPTION(createTypeError("Operator " + string(Token::toString(m_operator)) + + " not compatible with type " + + m_commonType->toString())); } } |