Disallow empty tuples on the left hand side

This commit is contained in:
a3d4
2020-04-23 07:02:04 +02:00
parent 9538024c81
commit c4bc77874b
2 changed files with 8 additions and 0 deletions
+3
View File
@@ -1288,6 +1288,9 @@ void TypeChecker::checkExpressionAssignment(Type const& _type, Expression const&
{
if (auto const* tupleExpression = dynamic_cast<TupleExpression const*>(&_expression))
{
if (tupleExpression->components().empty())
m_errorReporter.typeError(_expression.location(), "Empty tuple on the left hand side.");
auto const* tupleType = dynamic_cast<TupleType const*>(&_type);
auto const& types = tupleType && tupleExpression->components().size() != 1 ? tupleType->components() : vector<TypePointer> { &_type };