From b003290638e16e595c25e433f2f65648ea6644da Mon Sep 17 00:00:00 2001 From: Lu Guanqun Date: Thu, 7 Jan 2016 09:14:29 +0000 Subject: [cond-expr] fixup according to code review --- libsolidity/analysis/TypeChecker.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'libsolidity/analysis') 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; } -- cgit v1.2.3