aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp68
1 files changed, 25 insertions, 43 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index f3840675..8f1b2b9d 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -748,55 +748,37 @@ bool TypeChecker::visit(Conditional const& _conditional)
{
expectType(_conditional.condition(), BoolType());
- if (_conditional.annotation().lValueRequested)
- {
- requireLValue(_conditional.trueExpression());
- requireLValue(_conditional.falseExpression());
-
- TypePointer const& trueType = type(_conditional.trueExpression());
- TypePointer const& falseType = type(_conditional.falseExpression());
+ _conditional.trueExpression().accept(*this);
+ _conditional.falseExpression().accept(*this);
- // as a left value, we require exact match to prevent subtle conversion issues.
- if (*trueType != *falseType)
- typeError(
- _conditional.location(),
- "True expression's type " +
- trueType->toString() +
- " doesn't match false expression's type " +
- falseType->toString() +
- "."
- );
+ TypePointer const& trueType = type(_conditional.trueExpression());
+ TypePointer const& falseType = type(_conditional.falseExpression());
- _conditional.annotation().type = trueType;
- _conditional.annotation().isLValue = true;
- }
- else
+ // we fake it as an equal operator, but any other comparison operator can work.
+ TypePointer commonType = trueType->binaryOperatorResult(Token::Equal, falseType);
+ if (!commonType)
{
- _conditional.trueExpression().accept(*this);
- _conditional.falseExpression().accept(*this);
+ typeError(
+ _conditional.location(),
+ "True expression's type " +
+ trueType->toString() +
+ " doesn't match false expression's type " +
+ falseType->toString() +
+ "."
+ );
+ // even we can't find a common type, we have to set a type here,
+ // otherwise the upper statement will not be able to check the type.
+ commonType = trueType;
+ }
- TypePointer const& trueType = type(_conditional.trueExpression());
- TypePointer const& falseType = type(_conditional.falseExpression());
+ _conditional.annotation().type = commonType;
- // we fake it as an equal operator, but any other comparison operator can work.
- TypePointer commonType = trueType->binaryOperatorResult(Token::Equal, falseType);
- if (!commonType)
- {
- typeError(
- _conditional.location(),
- "True expression's type " +
- trueType->toString() +
- " doesn't match false expression's type " +
- falseType->toString() +
- "."
- );
- // even we can't find a common type, we have to set a type here,
- // otherwise the upper statement will not be able to check the type.
- commonType = trueType;
- }
+ if (_conditional.annotation().lValueRequested)
+ typeError(
+ _conditional.location(),
+ "Conditional expression as left value is not supported yet."
+ );
- _conditional.annotation().type = commonType;
- }
return false;
}