compiler: Treat map index expressions as lvalues in range expressions.

Fixes golang/go#9695.

From-SVN: r220301
This commit is contained in:
Ian Lance Taylor 2015-01-31 00:20:10 +00:00
parent a6b483da4d
commit 106aaf4f82

View File

@ -4011,6 +4011,16 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit,
token = this->advance_token();
if (lhs == NULL)
return;
// Map expressions act differently when they are lvalues.
for (Expression_list::iterator plv = lhs->begin();
plv != lhs->end();
++plv)
if ((*plv)->index_expression() != NULL)
(*plv)->index_expression()->set_is_lvalue();
if (p_range_clause != NULL && token->is_keyword(KEYWORD_RANGE))
{
if (op != OPERATOR_EQ)
@ -4023,7 +4033,7 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit,
may_be_composite_lit);
// We've parsed everything; check for errors.
if (lhs == NULL || vals == NULL)
if (vals == NULL)
return;
for (Expression_list::const_iterator pe = lhs->begin();
pe != lhs->end();
@ -4042,13 +4052,6 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit,
return;
}
// Map expressions act differently when they are lvalues.
for (Expression_list::iterator plv = lhs->begin();
plv != lhs->end();
++plv)
if ((*plv)->index_expression() != NULL)
(*plv)->index_expression()->set_is_lvalue();
Call_expression* call;
Index_expression* map_index;
Receive_expression* receive;