[cond-expr] add a test to assign memory to storage

This commit is contained in:
Lu Guanqun
2016-01-22 17:14:01 +00:00
parent 41039705ac
commit 1cd3288311
2 changed files with 39 additions and 2 deletions
+6 -2
View File
@@ -754,8 +754,12 @@ bool TypeChecker::visit(Conditional const& _conditional)
TypePointer const& trueType = type(_conditional.trueExpression());
TypePointer const& falseType = type(_conditional.falseExpression());
// we fake it as an equal operator, but any other comparison operator can work.
TypePointer commonType = trueType->binaryOperatorResult(Token::Equal, falseType);
TypePointer commonType;
if (*trueType == *falseType)
commonType = trueType;
else
// we fake it as an equal operator, but any other comparison operator can work.
TypePointer commonType = trueType->binaryOperatorResult(Token::Equal, falseType);
if (!commonType)
{
typeError(