aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-11-22 20:41:33 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-12-12 17:40:29 +0800
commit7ff9a85592cbb50b7a72654849582c780d7fc494 (patch)
tree282450de706a54a293878bc8b98abf5474801cdc /libsolidity/analysis
parent5226d54ed16bb7247c64ac67fec786301a3210ec (diff)
downloaddexon-solidity-7ff9a85592cbb50b7a72654849582c780d7fc494.tar.gz
dexon-solidity-7ff9a85592cbb50b7a72654849582c780d7fc494.tar.zst
dexon-solidity-7ff9a85592cbb50b7a72654849582c780d7fc494.zip
Reduce the types of errors outputted by ConstantEvaluator
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/ConstantEvaluator.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/libsolidity/analysis/ConstantEvaluator.cpp b/libsolidity/analysis/ConstantEvaluator.cpp
index 4d546e68..7f5ffb51 100644
--- a/libsolidity/analysis/ConstantEvaluator.cpp
+++ b/libsolidity/analysis/ConstantEvaluator.cpp
@@ -33,7 +33,7 @@ void ConstantEvaluator::endVisit(UnaryOperation const& _operation)
{
TypePointer const& subType = _operation.subExpression().annotation().type;
if (!dynamic_cast<RationalNumberType const*>(subType.get()))
- m_errorReporter.fatalTypeError(_operation.subExpression().location(), "Invalid constant expression.");
+ return;
TypePointer t = subType->unaryOperatorResult(_operation.getOperator());
_operation.annotation().type = t;
}
@@ -44,9 +44,9 @@ void ConstantEvaluator::endVisit(BinaryOperation const& _operation)
TypePointer const& leftType = _operation.leftExpression().annotation().type;
TypePointer const& rightType = _operation.rightExpression().annotation().type;
if (!dynamic_cast<RationalNumberType const*>(leftType.get()))
- m_errorReporter.fatalTypeError(_operation.leftExpression().location(), "Invalid constant expression.");
+ return;
if (!dynamic_cast<RationalNumberType const*>(rightType.get()))
- m_errorReporter.fatalTypeError(_operation.rightExpression().location(), "Invalid constant expression.");
+ return;
TypePointer commonType = leftType->binaryOperatorResult(_operation.getOperator(), rightType);
if (!commonType)
{
@@ -71,8 +71,6 @@ void ConstantEvaluator::endVisit(BinaryOperation const& _operation)
void ConstantEvaluator::endVisit(Literal const& _literal)
{
_literal.annotation().type = Type::forLiteral(_literal);
- if (!_literal.annotation().type)
- m_errorReporter.fatalTypeError(_literal.location(), "Invalid literal value.");
}
void ConstantEvaluator::endVisit(Identifier const& _identifier)
@@ -81,11 +79,11 @@ void ConstantEvaluator::endVisit(Identifier const& _identifier)
if (!variableDeclaration)
return;
if (!variableDeclaration->isConstant())
- m_errorReporter.fatalTypeError(_identifier.location(), "Identifier must be declared constant.");
+ return;
- ASTPointer<Expression> value = variableDeclaration->value();
+ ASTPointer<Expression> const& value = variableDeclaration->value();
if (!value)
- m_errorReporter.fatalTypeError(_identifier.location(), "Constant identifier declaration must have a constant value.");
+ return;
if (!value->annotation().type)
{