diff options
author | chriseth <chris@ethereum.org> | 2018-07-11 03:03:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-11 03:03:30 +0800 |
commit | 6567cd3e51a097b7bc8c2a3b37e6fa35bc8a5bbb (patch) | |
tree | 9d692f0c519b3d5004f2a7c7c2ac5aa0bbf72ee7 /libsolidity/analysis | |
parent | 0e9415bc31fa379b2c6cc8c8dba6b6ba1305391b (diff) | |
parent | 64abfd3e4a9f2d41946fa999545b98dbdf36ad14 (diff) | |
download | dexon-solidity-6567cd3e51a097b7bc8c2a3b37e6fa35bc8a5bbb.tar.gz dexon-solidity-6567cd3e51a097b7bc8c2a3b37e6fa35bc8a5bbb.tar.zst dexon-solidity-6567cd3e51a097b7bc8c2a3b37e6fa35bc8a5bbb.zip |
Merge pull request #4466 from ethereum/tupleNotEmpty
Disallow empty tuple components.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index a11b1879..81547bdf 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1408,14 +1408,12 @@ 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,). - if (!components[i] && !(i == 1 && components.size() == 2)) + if (!components[i]) m_errorReporter.fatalTypeError(_tuple.location(), "Tuple component cannot be empty."); else if (components[i]) { @@ -1427,10 +1425,7 @@ bool TypeChecker::visit(TupleExpression const& _tuple) { 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."); + m_errorReporter.typeError(components[i]->location(), "Tuple component cannot be empty."); } // Note: code generation will visit each of the expression even if they are not assigned from. @@ -1468,11 +1463,7 @@ bool TypeChecker::visit(TupleExpression const& _tuple) if (components.size() == 1) _tuple.annotation().type = type(*components[0]); else - { - if (components.size() == 2 && !components[1]) - types.pop_back(); _tuple.annotation().type = make_shared<TupleType>(types); - } } } |