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

ruby-changes:38321

From: nobu <ko1@a...>
Date: Thu, 30 Apr 2015 16:22:43 +0900 (JST)
Subject: [ruby-changes:38321] nobu:r50402 (trunk): parse.y: push cmdarg_stack

nobu	2015-04-30 16:22:19 +0900 (Thu, 30 Apr 2015)

  New Revision: 50402

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50402

  Log:
    parse.y: push cmdarg_stack
    
    * parse.y (lambda): push and reset cmdarg_stack in lambda body.
      [ruby-core:69017] [Bug #11107]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_syntax.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50401)
+++ ChangeLog	(revision 50402)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Apr 30 16:22:16 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (lambda): push and reset cmdarg_stack in lambda body.
+	  [ruby-core:69017] [Bug #11107]
+
 Sun Apr 26 07:36:48 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* enc/utf_8.c (code_to_mbclen, code_to_mbc): reject values larger
Index: parse.y
===================================================================
--- parse.y	(revision 50401)
+++ parse.y	(revision 50402)
@@ -3518,14 +3518,19 @@ lambda		:   { https://github.com/ruby/ruby/blob/trunk/parse.y#L3518
 		    {
 			$<num>$ = ruby_sourceline;
 		    }
+		    {
+			$<val>$ = cmdarg_stack;
+			cmdarg_stack = 0;
+		    }
 		  lambda_body
 		    {
 			lpar_beg = $<num>2;
+			cmdarg_stack = $<val>5;
 		    /*%%%*/
-			$$ = NEW_LAMBDA($3, $5);
+			$$ = NEW_LAMBDA($3, $6);
 			nd_set_line($$, $<num>4);
 		    /*%
-			$$ = dispatch2(lambda, $3, $5);
+			$$ = dispatch2(lambda, $3, $6);
 		    %*/
 			dyna_pop($<vars>1);
 		    }
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 50401)
+++ test/ruby/test_syntax.rb	(revision 50402)
@@ -400,6 +400,11 @@ WARN https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L400
     assert_valid_syntax("bar def foo; self.each do end end", bug9308)
   end
 
+  def test_do_block_in_lambda
+    bug11107 = '[ruby-core:69017] [Bug #11107]'
+    assert_valid_syntax('p ->() do a() do end end', bug11107)
+  end
+
   def test_reserved_method_no_args
     bug6403 = '[ruby-dev:45626]'
     assert_valid_syntax("def self; :foo; end", __FILE__, bug6403)

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

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