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

ruby-changes:58729

From: Nobuyoshi <ko1@a...>
Date: Tue, 12 Nov 2019 09:43:21 +0900 (JST)
Subject: [ruby-changes:58729] ed90ec3e0d (master): Clear current argument name at empty block argument [Bug #16343]

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

From ed90ec3e0d8ff7789569b40ba36d3b3ce0e706e6 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 12 Nov 2019 09:11:16 +0900
Subject: Clear current argument name at empty block argument [Bug #16343]


diff --git a/parse.y b/parse.y
index e84468d..dd55279 100644
--- a/parse.y
+++ b/parse.y
@@ -3455,6 +3455,7 @@ block_param_def	: '|' opt_bv_decl '|' https://github.com/ruby/ruby/blob/trunk/parse.y#L3455
 		    }
 		| tOROP
 		    {
+			p->cur_arg = 0;
 			p->max_numparam = ORDINAL_PARAM;
 		    /*%%%*/
 			$$ = 0;
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 5fb4dfa..ba479fa 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -243,6 +243,16 @@ class TestSyntax < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L243
 
     o = Object.new
     assert_warn("") do
+      o.instance_eval("def foo(var: bar {| | var}) var end")
+    end
+
+    o = Object.new
+    assert_warn("") do
+      o.instance_eval("def foo(var: bar {|| var}) var end")
+    end
+
+    o = Object.new
+    assert_warn("") do
       o.instance_eval("def foo(var: def bar(var) var; end) var end")
     end
 
@@ -298,6 +308,16 @@ class TestSyntax < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L308
 
     o = Object.new
     assert_warn("") do
+      o.instance_eval("def foo(var = bar {| | var}) var end")
+    end
+
+    o = Object.new
+    assert_warn("") do
+      o.instance_eval("def foo(var = bar {|| var}) var end")
+    end
+
+    o = Object.new
+    assert_warn("") do
       o.instance_eval("def foo(var = def bar(var) var; end) var end")
     end
 
-- 
cgit v0.10.2


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

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