@@ -375,9 +375,9 @@
this->advance_token();
else
{
- if (!may_use_ellipsis || !token->is_op(OPERATOR_ELLIPSIS))
+ if (!token->is_op(OPERATOR_ELLIPSIS))
length = this->expression(PRECEDENCE_NORMAL, false, true, NULL);
- else
+ else if (may_use_ellipsis)
{
// An ellipsis is used in composite literals to represent a
// fixed array of the size of the number of elements. We
@@ -386,6 +386,12 @@
length = Expression::make_nil(this->location());
this->advance_token();
}
+ else
+ {
+ this->error("use of %<[...]%> outside of array literal");
+ length = Expression::make_error(this->location());
+ this->advance_token();
+ }
if (!this->peek_token()->is_op(OPERATOR_RSQUARE))
{
this->error("expected %<]%>");
@@ -3418,7 +3418,8 @@
}
else
{
- error_at(this->length_->location(), "array bound is not numeric");
+ if (!t->is_error_type())
+ error_at(this->length_->location(), "array bound is not numeric");
return false;
}