mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow empty tuple components.
This commit is contained in:
parent
d9c3b10b1c
commit
a6e5a51d61
@ -1411,14 +1411,12 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool const v050 = m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050);
|
|
||||||
bool isPure = true;
|
bool isPure = true;
|
||||||
TypePointer inlineArrayType;
|
TypePointer inlineArrayType;
|
||||||
|
|
||||||
for (size_t i = 0; i < components.size(); ++i)
|
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])
|
||||||
if (!components[i] && !(i == 1 && components.size() == 2))
|
|
||||||
m_errorReporter.fatalTypeError(_tuple.location(), "Tuple component cannot be empty.");
|
m_errorReporter.fatalTypeError(_tuple.location(), "Tuple component cannot be empty.");
|
||||||
else if (components[i])
|
else if (components[i])
|
||||||
{
|
{
|
||||||
@ -1430,10 +1428,7 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
|
|||||||
{
|
{
|
||||||
if (_tuple.isInlineArray())
|
if (_tuple.isInlineArray())
|
||||||
m_errorReporter.fatalTypeError(components[i]->location(), "Array component cannot be empty.");
|
m_errorReporter.fatalTypeError(components[i]->location(), "Array component cannot be empty.");
|
||||||
if (v050)
|
m_errorReporter.typeError(components[i]->location(), "Tuple component cannot be empty.");
|
||||||
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.
|
// Note: code generation will visit each of the expression even if they are not assigned from.
|
||||||
|
Loading…
Reference in New Issue
Block a user