summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parse.y6
-rw-r--r--test/ruby/test_syntax.rb5
2 files changed, 11 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 6fc098bc6e..bf6c726024 100644
--- a/parse.y
+++ b/parse.y
@@ -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, &@$);
/*% %*/
@@ -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, &@$);
/*% %*/
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 6fdca37924..8112b14690 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -976,6 +976,11 @@ eom
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")