[前][次][番号順一覧][スレッド一覧]

ruby-changes:56112

From: Nobuyoshi <ko1@a...>
Date: Fri, 14 Jun 2019 18:21:23 +0900 (JST)
Subject: [ruby-changes:56112] Nobuyoshi Nakada: d365fd5a02 (trunk): An operator is not allowed just after `|>`

https://git.ruby-lang.org/ruby.git/commit/?id=d365fd5a02

From d365fd5a024254d7c105a62a015a7ea29ccf3e5d Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Fri, 14 Jun 2019 18:09:45 +0900
Subject: An operator is not allowed just after `|>`

https://twitter.com/yukihiro_matz/status/1139454774640726019

diff --git a/parse.y b/parse.y
index 58f0e4b..ff0afed 100644
--- a/parse.y
+++ b/parse.y
@@ -1499,28 +1499,28 @@ expr		: command_call https://github.com/ruby/ruby/blob/trunk/parse.y#L1499
 		| pipeline
 		;
 
-pipeline	: expr tPIPE operation2 opt_paren_args
+pipeline	: expr tPIPE operation opt_paren_args
 		    {
 		    /*%%%*/
 			$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, Qnull, &@3, &@$);
 		    /*% %*/
 		    /*% ripper: command_call!($1, ID2VAL(idPIPE), $3, $4) %*/
 		    }
-		| expr tPIPE operation2 opt_paren_args brace_block
+		| expr tPIPE operation opt_paren_args brace_block
 		    {
 		    /*%%%*/
 			$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, $5, &@3, &@$);
 		    /*% %*/
 		    /*% ripper: method_add_block!(command_call!($1, ID2VAL(idPIPE), $3, $4), $5) %*/
 		    }
-		| expr tPIPE operation2 command_args
+		| expr tPIPE operation command_args
 		    {
 		    /*%%%*/
 			$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, Qnull, &@3, &@$);
 		    /*% %*/
 		    /*% ripper: command_call!($1, ID2VAL(idPIPE), $3, $4) %*/
 		    }
-		| expr tPIPE operation2 command_args do_block
+		| expr tPIPE operation command_args do_block
 		    {
 		    /*%%%*/
 			$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, $5, &@3, &@$);
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index d2638c7..4e8ffe5 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -1385,6 +1385,7 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L1385
     assert_equal("121", eval('x = 12 |> pow(2) |> to_s 11'))
     assert_equal(12, x)
     assert_equal([2, 4, 6], eval("1.. |> take 3\n|> map do @1 * 2 end"))
+    assert_syntax_error('a|>-b', /unexpected '-'/)
   end
 
   private
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]