aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorLu Guanqun <guanqun.lu@gmail.com>2016-01-07 17:14:29 +0800
committerLu Guanqun <guanqun.lu@gmail.com>2016-01-23 01:14:00 +0800
commitb003290638e16e595c25e433f2f65648ea6644da (patch)
tree43acc605fae38011d22a2e01a820ff36d2154348 /libsolidity/analysis
parent82ee9503e9b3af35b55318f03caf3dc311a57539 (diff)
downloaddexon-solidity-b003290638e16e595c25e433f2f65648ea6644da.tar
dexon-solidity-b003290638e16e595c25e433f2f65648ea6644da.tar.gz
dexon-solidity-b003290638e16e595c25e433f2f65648ea6644da.tar.bz2
dexon-solidity-b003290638e16e595c25e433f2f65648ea6644da.tar.lz
dexon-solidity-b003290638e16e595c25e433f2f65648ea6644da.tar.xz
dexon-solidity-b003290638e16e595c25e433f2f65648ea6644da.tar.zst
dexon-solidity-b003290638e16e595c25e433f2f65648ea6644da.zip
[cond-expr] fixup according to code review
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index f2056474..f3840675 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -765,7 +765,7 @@ bool TypeChecker::visit(Conditional const& _conditional)
" doesn't match false expression's type " +
falseType->toString() +
"."
- );
+ );
_conditional.annotation().type = trueType;
_conditional.annotation().isLValue = true;
@@ -781,6 +781,7 @@ bool TypeChecker::visit(Conditional const& _conditional)
// 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 " +
@@ -788,7 +789,11 @@ bool TypeChecker::visit(Conditional const& _conditional)
" 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;
+ }
_conditional.annotation().type = commonType;
}