* parse.y (command_asgn, arg): fix syntax errors with chained
  assignment with op assign.  [Bug #12669]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-08-13 02:10:11 +00:00
Родитель 5245e31426
Коммит 90d9255ec2
3 изменённых файлов: 37 добавлений и 22 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Sat Aug 13 11:10:08 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (command_asgn, arg): fix syntax errors with chained
assignment with op assign. [Bug #12669]
Sat Aug 13 10:52:19 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (stmt, arg): rescue modifier in command op assignment

44
parse.y
Просмотреть файл

@ -1284,6 +1284,28 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
$$ = dispatch2(massign, $1, $3);
%*/
}
| lhs '=' mrhs
{
value_expr($3);
$$ = node_assign($1, $3);
}
| mlhs '=' mrhs_arg
{
/*%%%*/
$1->nd_value = $3;
$$ = $1;
/*%
$$ = dispatch2(massign, $1, $3);
%*/
}
| expr
;
command_asgn : lhs '=' command_rhs
{
value_expr($3);
$$ = node_assign($1, $3);
}
| var_lhs tOP_ASGN command_rhs
{
value_expr($3);
@ -1335,28 +1357,6 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
$1 = var_field($1);
$$ = backref_assign_error($1, node_assign($1, $3));
}
| lhs '=' mrhs
{
value_expr($3);
$$ = node_assign($1, $3);
}
| mlhs '=' mrhs_arg
{
/*%%%*/
$1->nd_value = $3;
$$ = $1;
/*%
$$ = dispatch2(massign, $1, $3);
%*/
}
| expr
;
command_asgn : lhs '=' command_rhs
{
value_expr($3);
$$ = node_assign($1, $3);
}
;
command_rhs : command_call %prec tOP_ASGN

Просмотреть файл

@ -771,4 +771,14 @@ class TestAssignmentGen < Test::Unit::TestCase
h[*k], = ["ok", "ng"]
assert_equal("ok", h[:key], bug11970)
end
def test_chainged_assign_command
all_assertions do |a|
asgn = %w'= +='
asgn.product(asgn) do |a1, a2|
stmt = "a #{a1} b #{a2} raise 'x'"
a.for(stmt) {assert_valid_syntax(stmt)}
end
end
end
end