ruby-changes:56079
From: Nobuyoshi <ko1@a...>
Date: Tue, 11 Jun 2019 15:25:44 +0900 (JST)
Subject: [ruby-changes:56079] Nobuyoshi Nakada: 140b8117bd (trunk): &. is not allowed inside LHS of massign
https://git.ruby-lang.org/ruby.git/commit/?id=140b8117bd From 140b8117bd3c32cb9d0b144937b90f0178a00b0e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 11 Jun 2019 02:09:00 +0900 Subject: &. is not allowed inside LHS of massign https://hackerone.com/reports/605262 diff --git a/parse.y b/parse.y index 6fc098b..bf6c726 100644 --- a/parse.y +++ b/parse.y @@ -1787,6 +1787,9 @@ mlhs_node : user_variable https://github.com/ruby/ruby/blob/trunk/parse.y#L1787 } | 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 https://github.com/ruby/ruby/blob/trunk/parse.y#L1804 } | 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 6fdca37..8112b14 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -976,6 +976,11 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L976 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") -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/