aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-04-23 23:35:00 +0800
committerGitHub <noreply@github.com>2018-04-23 23:35:00 +0800
commite685f9f59ecf13210eb7a32156d556a4cdd8ff58 (patch)
treeaf376d07e441f26afbca94586e4e3b69ac517d30 /libsolidity/analysis
parentc7ee2ca0b9eb6c36ddb15b70f341975bdff47aad (diff)
parent896018c8a33f92e9dd507b462c858dbcf13d6385 (diff)
downloaddexon-solidity-e685f9f59ecf13210eb7a32156d556a4cdd8ff58.tar.gz
dexon-solidity-e685f9f59ecf13210eb7a32156d556a4cdd8ff58.tar.zst
dexon-solidity-e685f9f59ecf13210eb7a32156d556a4cdd8ff58.zip
Merge pull request #3976 from ethereum/emptyTupleComponent
Empty tuple components should not be possible
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 40162322..ce98eb24 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1406,8 +1406,10 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
}
else
{
+ bool const v050 = m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
bool isPure = true;
TypePointer inlineArrayType;
+
for (size_t i = 0; i < components.size(); ++i)
{
// Outside of an lvalue-context, the only situation where a component can be empty is (x,).
@@ -1418,6 +1420,17 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
components[i]->accept(*this);
types.push_back(type(*components[i]));
+ if (types[i]->category() == Type::Category::Tuple)
+ if (dynamic_cast<TupleType const&>(*types[i]).components().empty())
+ {
+ if (_tuple.isInlineArray())
+ m_errorReporter.fatalTypeError(components[i]->location(), "Array component cannot be empty.");
+ if (v050)
+ m_errorReporter.fatalTypeError(components[i]->location(), "Tuple component cannot be empty.");
+ else
+ m_errorReporter.warning(components[i]->location(), "Tuple component cannot be empty.");
+ }
+
// Note: code generation will visit each of the expression even if they are not assigned from.
if (types[i]->category() == Type::Category::RationalNumber && components.size() > 1)
if (!dynamic_cast<RationalNumberType const&>(*types[i]).mobileType())