aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLu Guanqun <guanqun.lu@gmail.com>2016-01-04 16:11:04 +0800
committerLu Guanqun <guanqun.lu@gmail.com>2016-01-04 16:11:36 +0800
commit568da1136992f8f188ba419bef814659f7a7794a (patch)
tree947396ddacbf9ed3d86434826b501a82f9ac7674
parent6b711d0527823ff6287fe869579260bb27feacdd (diff)
downloaddexon-solidity-568da1136992f8f188ba419bef814659f7a7794a.tar
dexon-solidity-568da1136992f8f188ba419bef814659f7a7794a.tar.gz
dexon-solidity-568da1136992f8f188ba419bef814659f7a7794a.tar.bz2
dexon-solidity-568da1136992f8f188ba419bef814659f7a7794a.tar.lz
dexon-solidity-568da1136992f8f188ba419bef814659f7a7794a.tar.xz
dexon-solidity-568da1136992f8f188ba419bef814659f7a7794a.tar.zst
dexon-solidity-568da1136992f8f188ba419bef814659f7a7794a.zip
support decayed tuple expression as left value
-rw-r--r--libsolidity/analysis/TypeChecker.cpp5
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp7
2 files changed, 10 insertions, 2 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 9718bf75..de30dcf7 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -792,7 +792,10 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
}
else
types.push_back(TypePointer());
- _tuple.annotation().type = make_shared<TupleType>(types);
+ if (components.size() == 1)
+ _tuple.annotation().type = type(*components[0]);
+ else
+ _tuple.annotation().type = make_shared<TupleType>(types);
// If some of the components are not LValues, the error is reported above.
_tuple.annotation().isLValue = true;
}
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index 2fd0b2c4..b0e92b59 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -233,7 +233,12 @@ bool ExpressionCompiler::visit(TupleExpression const& _tuple)
else if (_tuple.annotation().lValueRequested)
lvalues.push_back(unique_ptr<LValue>());
if (_tuple.annotation().lValueRequested)
- m_currentLValue.reset(new TupleObject(m_context, move(lvalues)));
+ {
+ if (_tuple.components().size() == 1)
+ m_currentLValue = move(lvalues[0]);
+ else
+ m_currentLValue.reset(new TupleObject(m_context, move(lvalues)));
+ }
return false;
}