Skip to content

Commit

Permalink
&. is not allowed inside LHS of massign
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Jun 11, 2019
1 parent 42ac889 commit 140b811
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions parse.y
Expand Up @@ -1787,6 +1787,9 @@ mlhs_node : user_variable
}
| primary_value call_op tIDENTIFIER
{
if ($2 == tANDDOT) {
yyerror1(&@2, "&. inside LHS of multiple assignment");
}
/*%%%*/
$$ = attrset(p, $1, $2, $3, &@$);
/*% %*/
Expand All @@ -1801,6 +1804,9 @@ mlhs_node : user_variable
}
| primary_value call_op tCONSTANT
{
if ($2 == tANDDOT) {
yyerror1(&@2, "&. inside LHS of multiple assignment");
}
/*%%%*/
$$ = attrset(p, $1, $2, $3, &@$);
/*% %*/
Expand Down
5 changes: 5 additions & 0 deletions test/ruby/test_syntax.rb
Expand Up @@ -976,6 +976,11 @@ def test_fluent_dot
assert_valid_syntax("a\n.:foo")
end

def test_safe_call_in_massign_lhs
assert_syntax_error("*a&.x=0", /LHS/)
assert_syntax_error("a&.x,=0", /LHS/)
end

def test_no_warning_logop_literal
assert_warning("") do
eval("true||raise;nil")
Expand Down

0 comments on commit 140b811

Please sign in to comment.