still not able to get types resolved, however it is compiling

This commit is contained in:
RJ Catalano 2015-12-15 16:44:11 -06:00
parent 9ab066de8c
commit c8e4e9c05c

View File

@ -779,6 +779,7 @@ bool TypeChecker::visit(Assignment const& _assignment)
bool TypeChecker::visit(TupleExpression const& _tuple) bool TypeChecker::visit(TupleExpression const& _tuple)
{ {
vector<ASTPointer<Expression>> const& components = _tuple.components(); vector<ASTPointer<Expression>> const& components = _tuple.components();
TypePointers types; TypePointers types;
if (_tuple.annotation().lValueRequested) if (_tuple.annotation().lValueRequested)
@ -791,7 +792,10 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
} }
else else
types.push_back(TypePointer()); types.push_back(TypePointer());
_tuple.annotation().type = make_shared<TupleType>(types); if (_tuple.isInlineArray())
_tuple.annotation().type = make_shared<ArrayType>(DataLocation::Storage, _tuple.annotation().type, types.size());
else
_tuple.annotation().type = make_shared<TupleType>(types);
// If some of the components are not LValues, the error is reported above. // If some of the components are not LValues, the error is reported above.
_tuple.annotation().isLValue = true; _tuple.annotation().isLValue = true;
} }
@ -801,7 +805,10 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
{ {
// Outside of an lvalue-context, the only situation where a component can be empty is (x,). // 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] && !(i == 1 && components.size() == 2))
fatalTypeError(_tuple.location(), "Tuple component cannot be empty."); _tuple.isInlineArray() ?
fatalTypeError(_tuple.location(), "Array component cannot have empty cells.")
:
fatalTypeError(_tuple.location(), "Tuple component cannot be empty.");
else if (components[i]) else if (components[i])
{ {
components[i]->accept(*this); components[i]->accept(*this);