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

ruby-changes:32370

From: nobu <ko1@a...>
Date: Sat, 28 Dec 2013 00:42:59 +0900 (JST)
Subject: [ruby-changes:32370] nobu:r44449 (trunk): parse.y: save cmdarg_stack in local scope

nobu	2013-12-28 00:42:49 +0900 (Sat, 28 Dec 2013)

  New Revision: 44449

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

  Log:
    parse.y: save cmdarg_stack in local scope
    
    * parse.y (local_push_gen, local_pop_gen): save cmdarg_stack to
      isolate command argument state from outer scope.
      [ruby-core:59342] [Bug #9308]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_syntax.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44448)
+++ ChangeLog	(revision 44449)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Dec 28 00:42:37 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (local_push_gen, local_pop_gen): save cmdarg_stack to
+	  isolate command argument state from outer scope.
+	  [ruby-core:59342] [Bug #9308]
+
 Fri Dec 27 13:25:03 2013  NAKAMURA Usaku  <usa@r...>
 
 	* win32/{setup.mak,Makefile.sub}: update fake.rb like
Index: parse.y
===================================================================
--- parse.y	(revision 44448)
+++ parse.y	(revision 44449)
@@ -130,6 +130,7 @@ struct local_vars { https://github.com/ruby/ruby/blob/trunk/parse.y#L130
     struct vtable *vars;
     struct vtable *used;
     struct local_vars *prev;
+    stack_type cmdargs;
 };
 
 #define DVARS_INHERIT ((void*)1)
@@ -9647,6 +9648,8 @@ local_push_gen(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/parse.y#L9648
     local->used = !(inherit_dvars &&
 		    (ifndef_ripper(compile_for_eval || e_option_supplied(parser))+0)) &&
 	RTEST(ruby_verbose) ? vtable_alloc(0) : 0;
+    local->cmdargs = cmdarg_stack;
+    cmdarg_stack = 0;
     lvtbl = local;
 }
 
@@ -9660,6 +9663,7 @@ local_pop_gen(struct parser_params *pars https://github.com/ruby/ruby/blob/trunk/parse.y#L9663
     }
     vtable_free(lvtbl->args);
     vtable_free(lvtbl->vars);
+    cmdarg_stack = lvtbl->cmdargs;
     xfree(lvtbl);
     lvtbl = local;
 }
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 44448)
+++ test/ruby/test_syntax.rb	(revision 44449)
@@ -256,6 +256,11 @@ WARN https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L256
     assert_valid_syntax("p begin 1.times do 1 end end", __FILE__, bug6419)
   end
 
+  def test_do_block_in_call_args
+    bug9308 = '[ruby-core:59342] [Bug #9308]'
+    assert_valid_syntax("bar def foo; self.each do end end", bug9308)
+  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/

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